pub enum ByteType {
None,
Ascii(u8),
One(u8),
Two(u8),
Three(u8),
FourOrMore(u8),
Continuation(u8),
}Expand description
Represents UTF-8 byte type based on the most significant bits the given byte
Examples
use utf8_rune::ByteType;
let f0 = ByteType::from(0xf0u8);
assert_eq!(f0, ByteType::FourOrMore(0xF0));
assert_eq!(f0.len(), 4);
assert_eq!(f0.is_ascii(), false);
assert_eq!(f0.is_continuation(), false);use utf8_rune::ByteType;
let e4 = ByteType::from(0xE4u8);
assert_eq!(e4, ByteType::Three(0xE4));
assert_eq!(e4.len(), 3);
assert_eq!(e4.is_ascii(), false);
assert_eq!(e4.is_continuation(), false);use utf8_rune::ByteType;
let c3 = ByteType::from(0xC3u8);
assert_eq!(c3, ByteType::Two(0xC3));
assert_eq!(c3.len(), 2);
assert_eq!(c3.is_ascii(), false);
assert_eq!(c3.is_continuation(), false);use utf8_rune::ByteType;
let g = ByteType::from(b'g');
assert_eq!(g, ByteType::Ascii(0x67));
assert_eq!(g.len(), 1);
assert_eq!(g.is_ascii(), true);
assert_eq!(g.is_continuation(), false);use utf8_rune::ByteType;
let g = ByteType::from(0x80u8);
assert_eq!(g, ByteType::Continuation(0x80));
assert_eq!(g.len(), 1);
assert_eq!(g.is_ascii(), false);
assert_eq!(g.is_continuation(), true);Variants§
Implementations§
Trait Implementations§
impl Copy for ByteType
impl Eq for ByteType
impl StructuralPartialEq for ByteType
Auto Trait Implementations§
impl Freeze for ByteType
impl RefUnwindSafe for ByteType
impl Send for ByteType
impl Sync for ByteType
impl Unpin for ByteType
impl UnwindSafe for ByteType
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