[][src]Struct langtag::Variants

pub struct Variants<T: ?Sized = [u8]> { /* fields omitted */ }

List of variant subtags.

Represents a list of variant subtags separated by a - character as found in a language tag.

Implementations

impl<T: AsRef<[u8]>> Variants<T>[src]

pub fn new(t: T) -> Result<Variants<T>, Error>[src]

Parse and use the given data.

pub unsafe fn new_unchecked(t: T) -> Variants<T>[src]

Use the given data as buffer without parsing it.

Safety

The given data must be syntactically correct.

impl Variants<[u8]>[src]

pub fn parse<'a, T: AsRef<[u8]> + ?Sized>(
    bytes: &'a T
) -> Result<&'a Variants<[u8]>, Error>
[src]

Parse and borrow the given data.

pub unsafe fn parse_unchecked<'a, T: AsRef<[u8]> + ?Sized>(
    bytes: &'a T
) -> &'a Variants<[u8]>
[src]

Borrow the given data without checking that it is syntactically correct.

Safety

The data must be syntactically correct.

impl Variants<Vec<u8>>[src]

pub fn parse_copy<'a, T: AsRef<[u8]> + ?Sized>(
    bytes: &'a T
) -> Result<Variants<Vec<u8>>, Error>
[src]

Parse and copy the input data.

pub unsafe fn parse_copy_unchecked<'a, T: AsRef<[u8]> + ?Sized>(
    bytes: &'a T
) -> Variants<Vec<u8>>
[src]

Copy the input data without checking its syntax correctness.

Safety

The input data must be syntactically correct.

impl<T: AsRef<[u8]> + ?Sized> Variants<T>[src]

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

Bytes length.

pub fn as_bytes(&self) -> &[u8][src]

Return a reference to the underlying data.

pub fn as_str(&self) -> &str[src]

Return a reference to the underlying data as a string.

impl Variants[src]

pub fn empty() -> &'static Variants[src]

Empty list (the empty string).

pub fn is_empty(&self) -> bool[src]

Checks if the list is empty.

pub fn first(&self) -> Option<&Variant>[src]

Returns the first subtag of the list (if any).

pub fn last(&self) -> Option<&Variant>[src]

Returns the last subtag of the list (if any).

pub fn iter(&self) -> VariantsIter<'_>

Notable traits for VariantsIter<'a>

impl<'a> Iterator for VariantsIter<'a> type Item = &'a Variant;
[src]

Iterate through the subtags of the list.

pub fn contains<T: AsRef<[u8]> + ?Sized>(&self, subtag: &T) -> bool[src]

Checks if the given subtag is included the list.

Trait Implementations

impl<T: AsRef<[u8]> + ?Sized> AsRef<[u8]> for Variants<T>[src]

impl<T: AsRef<[u8]> + ?Sized> AsRef<str> for Variants<T>[src]

impl<T: AsRef<[u8]> + ?Sized> Debug for Variants<T>[src]

impl<T: ?Sized> Deref for Variants<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T: AsRef<[u8]> + ?Sized> Display for Variants<T>[src]

impl<T: AsRef<[u8]> + ?Sized> Eq for Variants<T>[src]

impl<T: AsRef<[u8]> + ?Sized> Hash for Variants<T>[src]

impl<'a> IntoIterator for &'a Variants[src]

type Item = &'a Variant

The type of the elements being iterated over.

type IntoIter = VariantsIter<'a>

Which kind of iterator are we turning this into?

impl<T: AsRef<[u8]> + ?Sized> Ord for Variants<T>[src]

impl<T: AsRef<[u8]> + ?Sized> PartialEq<[u8]> for Variants<T>[src]

impl<T: AsRef<[u8]> + ?Sized> PartialEq<Variants<T>> for [u8][src]

impl<T: AsRef<[u8]> + ?Sized> PartialEq<Variants<T>> for str[src]

impl<T: AsRef<[u8]> + ?Sized, U: AsRef<[u8]> + ?Sized> PartialEq<Variants<U>> for Variants<T>[src]

impl<T: AsRef<[u8]> + ?Sized> PartialEq<str> for Variants<T>[src]

impl<T: AsRef<[u8]> + ?Sized, U: AsRef<[u8]> + ?Sized> PartialOrd<Variants<U>> for Variants<T>[src]

impl<'a> TryFrom<&'a [u8]> for &'a Variants<[u8]>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a str> for &'a Variants<[u8]>[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

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

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

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

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

impl<T: ?Sized> UnwindSafe for Variants<T> where
    T: UnwindSafe
[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<T> ToString for T where
    T: Display + ?Sized
[src]

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.