[−][src]Struct encode_unicode::Utf8Char
Store a char
as UTF-8 so it can be borrowed as a str
Has the same size as char
, and is a [u8;4]
with the invariant that the first nth bytes are valid UTF-8, and the remaining are zero.
Methods
impl Utf8Char
[src]
pub fn from_slice_start(src: &[u8]) -> Result<(Self, usize), InvalidUtf8Slice>
[src]
Validate the start of a UTF-8 slice and store it. Also returns how many bytes were needed.
If it's a str and you know it contains only one codepoint,
use .from_str()
to skip the validation.
pub fn from_array(utf8: [u8; 4]) -> Result<Self, InvalidUtf8Array>
[src]
Validate the array and store it.
pub fn len(self) -> usize
[src]
Result is 1...4 and identical to .as_ref().len()
or .as_char().len_utf8()
.
There is no .is_emty() because it would always return false.
pub fn to_char(self) -> char
[src]
Convert from UTF-8 to UTF-32
pub fn to_slice(self, dst: &mut [u8]) -> Option<usize>
[src]
Write the internal representation to a slice, and then returns the number of bytes written.
None
is returned if the buffer is too small; then the buffer is left unmodified.
A buffer of length four is always large enough.
pub fn to_array(self) -> ([u8; 4], usize)
[src]
Expose the internal array and the number of used bytes.
Trait Implementations
impl PartialEq<Utf8Char> for Utf8Char
[src]
impl AsRef<[u8]> for Utf8Char
[src]
impl AsRef<str> for Utf8Char
[src]
impl IntoIterator for Utf8Char
[src]
type Item = u8
The type of the elements being iterated over.
type IntoIter = Utf8Iterator
Which kind of iterator are we turning this into?
ⓘImportant traits for Utf8Iteratorfn into_iter(self) -> Utf8Iterator
[src]
Iterate over the byte values.
impl Default for Utf8Char
[src]
impl Ord for Utf8Char
[src]
fn cmp(&self, other: &Utf8Char) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl Clone for Utf8Char
[src]
fn clone(&self) -> Utf8Char
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl From<char> for Utf8Char
[src]
impl From<Utf8Char> for char
[src]
impl From<Utf8Char> for Utf8Iterator
[src]
impl Eq for Utf8Char
[src]
impl Copy for Utf8Char
[src]
impl PartialOrd<Utf8Char> for Utf8Char
[src]
fn partial_cmp(&self, other: &Utf8Char) -> Option<Ordering>
[src]
fn lt(&self, other: &Utf8Char) -> bool
[src]
fn le(&self, other: &Utf8Char) -> bool
[src]
fn gt(&self, other: &Utf8Char) -> bool
[src]
fn ge(&self, other: &Utf8Char) -> bool
[src]
impl Debug for Utf8Char
[src]
impl Hash for Utf8Char
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Deref for Utf8Char
[src]
impl FromStr for Utf8Char
[src]
type Err = FromStrError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, FromStrError>
[src]
The string must contain exactly one codepoint
impl Borrow<[u8]> for Utf8Char
[src]
impl Borrow<str> for Utf8Char
[src]
Auto Trait Implementations
Blanket Implementations
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,