Struct roe::Uppercase[][src]

#[must_use = "Uppercase is a Iterator and must be used"]pub struct Uppercase<'a> { /* fields omitted */ }

An iterator that yields the uppercase equivalent of a conventionally UTF-8 byte string.

This iterator yields bytes.

This struct is created by the uppercase function. See its documentation for more.

Implementations

impl<'a> Uppercase<'a>[src]

pub const fn new() -> Self[src]

Create a new, empty uppercase iterator.

Examples

let mut uppercase = Uppercase::new();
assert_eq!(uppercase.next(), None);

pub const fn with_slice(slice: &'a [u8]) -> Self[src]

Create a new uppercase iterator with the given byte slice using full Unicode case mapping.

Examples

let mut uppercase = Uppercase::with_slice(b"abcXYZ");
assert_eq!(uppercase.next(), Some(b'A'));
assert_eq!(uppercase.next(), Some(b'B'));
assert_eq!(uppercase.next(), Some(b'C'));
assert_eq!(uppercase.next(), Some(b'X'));
assert_eq!(uppercase.next(), Some(b'Y'));
assert_eq!(uppercase.next(), Some(b'Z'));
assert_eq!(uppercase.next(), None);

Non-ASCII characters are case mapped:

let uppercase = Uppercase::with_slice("Αύριο".as_bytes());
assert_eq!(uppercase.collect::<Vec<_>>(), "ΑΎΡΙΟ".as_bytes());

Invalid UTF-8 bytes are yielded as is without impacting Unicode characters:

let mut s = "Αύριο".to_string().into_bytes();
s.extend(b"\xFF\xFE");
let uppercase = Uppercase::with_slice(s.as_slice());

let mut expected = "ΑΎΡΙΟ".to_string().into_bytes();
expected.extend(b"\xFF\xFE");
assert_eq!(uppercase.collect::<Vec<_>>(), expected);

pub const fn with_ascii_slice(slice: &'a [u8]) -> Self[src]

Create a new uppercase iterator with the given byte slice using ASCII case mapping.

Examples

let mut uppercase = Uppercase::with_ascii_slice(b"abcXYZ");
assert_eq!(uppercase.next(), Some(b'A'));
assert_eq!(uppercase.next(), Some(b'B'));
assert_eq!(uppercase.next(), Some(b'C'));
assert_eq!(uppercase.next(), Some(b'X'));
assert_eq!(uppercase.next(), Some(b'Y'));
assert_eq!(uppercase.next(), Some(b'Z'));
assert_eq!(uppercase.next(), None);

Non-ASCII characters are ignored:

let uppercase = Uppercase::with_ascii_slice("Αύριο".as_bytes());
assert_eq!(uppercase.collect::<Vec<_>>(), "Αύριο".as_bytes());

Invalid UTF-8 bytes are yielded as is without impacting ASCII bytes:

let uppercase = Uppercase::with_ascii_slice(b"abc\xFF\xFEXYZ");
assert_eq!(uppercase.collect::<Vec<_>>(), b"ABC\xFF\xFEXYZ");

Trait Implementations

impl<'a> Clone for Uppercase<'a>[src]

impl<'a> Debug for Uppercase<'a>[src]

impl<'a> FusedIterator for Uppercase<'a>[src]

impl<'a> Iterator for Uppercase<'a>[src]

type Item = u8

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Uppercase<'a>[src]

impl<'a> Send for Uppercase<'a>[src]

impl<'a> Sync for Uppercase<'a>[src]

impl<'a> Unpin for Uppercase<'a>[src]

impl<'a> UnwindSafe for Uppercase<'a>[src]

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<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.