[][src]Struct encode_unicode::Utf16Char

pub struct Utf16Char { /* fields omitted */ }

Store a char as UTF-16 so it can be borrowed as a slice

Size is identical to char. Cannot represent all 2^32-1 possible values, but can do all valid ones.

Methods

impl Utf16Char[src]

pub fn from_slice(src: &[u16]) -> Result<(Self, usize), InvalidUtf16Slice>[src]

Validate and store the first UTF-16 codepoint in the slice. Also return how many units were needed.

pub fn from_tuple(utf16: (u16, Option<u16>)) -> Result<Self, InvalidUtf16Tuple>[src]

Validate and store a UTF-16 pair as returned from char.to_utf16_tuple().

pub fn len(self) -> usize[src]

Returns 1 or 2. There is no .is_emty() because it would always return false.

pub fn to_char(self) -> char[src]

Convert from UTF-16 to UTF-32

pub fn to_slice(self, dst: &mut [u16]) -> Option<usize>[src]

Write the internal representation to a slice, and then returns the number of u16s written.

None is returned if the buffer is too small; then the buffer is left unmodified. A buffer of length two is always large enough.

pub fn to_tuple(self) -> (u16, Option<u16>)[src]

The second u16 is used for surrogate pairs.

Trait Implementations

impl PartialEq<Utf16Char> for Utf16Char[src]

impl AsRef<[u16]> for Utf16Char[src]

impl IntoIterator for Utf16Char[src]

type Item = u16

The type of the elements being iterated over.

type IntoIter = Utf16Iterator

Which kind of iterator are we turning this into?

Important traits for Utf16Iterator
fn into_iter(self) -> Utf16Iterator[src]

Iterate over the units.

impl Default for Utf16Char[src]

impl Ord for Utf16Char[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 Utf16Char[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl From<char> for Utf16Char[src]

impl From<Utf16Char> for char[src]

impl From<Utf16Char> for Utf16Iterator[src]

impl Eq for Utf16Char[src]

impl Copy for Utf16Char[src]

impl PartialOrd<Utf16Char> for Utf16Char[src]

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Debug for Utf16Char[src]

impl Hash for Utf16Char[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Deref for Utf16Char[src]

type Target = [u16]

The resulting type after dereferencing.

impl Borrow<[u16]> for Utf16Char[src]

Auto Trait Implementations

impl Send for Utf16Char

impl Sync for Utf16Char

Blanket Implementations

impl<I> IntoIterator for I where
    I: Iterator
[src]

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?

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]