pub enum ByteParser {
Decimal = 10,
Hexadecimal = 16,
}
Expand description
Parse a byte string into an unsigned integer.
This enum parses byte strings comprising decimal or hexadecimal ASCII digits
into u16
or u32
. Its methods are const
, with the implementation
working around the limitations of const
Rust, notably by using a macro to
unwrap options instead of the ?
operator.
§Example
assert_eq!(
ByteParser::Hexadecimal.to_u16(b"ffff"),
Some(0xffff)
);
assert_eq!(
ByteParser::Decimal.to_u16(b"65536"),
None
);
Variants§
Implementations§
Trait Implementations§
Source§impl Clone for ByteParser
impl Clone for ByteParser
Source§fn clone(&self) -> ByteParser
fn clone(&self) -> ByteParser
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ByteParser
impl Debug for ByteParser
Source§impl PartialEq for ByteParser
impl PartialEq for ByteParser
impl Copy for ByteParser
impl Eq for ByteParser
impl StructuralPartialEq for ByteParser
Auto Trait Implementations§
impl Freeze for ByteParser
impl RefUnwindSafe for ByteParser
impl Send for ByteParser
impl Sync for ByteParser
impl Unpin for ByteParser
impl UnwindSafe for ByteParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more