Struct encode_unicode::iterator::Utf16CharMerger[][src]

pub struct Utf16CharMerger<B: Borrow<u16>, I: Iterator<Item = B>> { /* fields omitted */ }

Decodes UTF-16 characters from a u16 iterator into Utf16Chars.

See IterExt::to_utf16chars() for examples and error handling.

Implementations

impl<B: Borrow<u16>, I: Iterator<Item = B>> Utf16CharMerger<B, I>[src]

pub fn into_inner(self) -> I[src]

Extract the inner iterator.

If the last item produced was an Err, the first unit might be missing.

Examples

Unit right after an error missing

let mut merger = [0xd901, 'F' as u16, 'S' as u16].iter().to_utf16chars();
assert_eq!(merger.next(), Some(Err(Utf16PairError::UnmatchedLeadingSurrogate)));
let mut inner: std::slice::Iter<u16> = merger.into_inner();
assert_eq!(inner.next(), Some('S' as u16).as_ref()); // 'F' was consumed by Utf16CharMerger

Error that doesn’t swallow any units

let mut merger = [0xde00, 'F' as u16, 'S' as u16].iter().to_utf16chars();
assert_eq!(merger.next(), Some(Err(Utf16PairError::UnexpectedTrailingSurrogate)));
let mut inner: std::slice::Iter<u16> = merger.into_inner();
assert_eq!(inner.next(), Some('F' as u16).as_ref()); // not consumed

pub fn into_remaining_units(self) -> Chain<IntoIter<B>, I>[src]

Returns an iterator over the remaining units. Unlike into_inner() this will never drop any units.

The exact type of the returned iterator should not be depended on.

Examples

let slice = [0xd901, 'F' as u16, 'S' as u16];
let mut merger = slice.iter().to_utf16chars();
assert_eq!(merger.next(), Some(Err(Utf16PairError::UnmatchedLeadingSurrogate)));
let mut remaining = merger.into_remaining_units();
assert_eq!(remaining.next(), Some('F' as u16).as_ref());

Trait Implementations

impl<B: Clone + Borrow<u16>, I: Clone + Iterator<Item = B>> Clone for Utf16CharMerger<B, I>[src]

impl<B: Borrow<u16>, I: Iterator<Item = B> + Debug> Debug for Utf16CharMerger<B, I>[src]

impl<B: Default + Borrow<u16>, I: Default + Iterator<Item = B>> Default for Utf16CharMerger<B, I>[src]

impl<B: Borrow<u16>, I: Iterator<Item = B>, T: IntoIterator<IntoIter = I, Item = B>> From<T> for Utf16CharMerger<B, I>[src]

impl<B: Borrow<u16>, I: Iterator<Item = B>> Iterator for Utf16CharMerger<B, I>[src]

type Item = Result<Utf16Char, Utf16PairError>

The type of the elements being iterated over.

Auto Trait Implementations

impl<B, I> RefUnwindSafe for Utf16CharMerger<B, I> where
    B: RefUnwindSafe,
    I: RefUnwindSafe

impl<B, I> Send for Utf16CharMerger<B, I> where
    B: Send,
    I: Send

impl<B, I> Sync for Utf16CharMerger<B, I> where
    B: Sync,
    I: Sync

impl<B, I> Unpin for Utf16CharMerger<B, I> where
    B: Unpin,
    I: Unpin

impl<B, I> UnwindSafe for Utf16CharMerger<B, I> where
    B: UnwindSafe,
    I: UnwindSafe

Blanket Implementations

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

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

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

impl<T> From<!> for T[src]

impl<T> From<T> for T[src]

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

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.