Struct icu_locid::extensions::unicode::Attribute[][src]

pub struct Attribute(_);

An attribute used in a set of Attributes.

An attribute has to be a sequence of alphanumerical characters no shorter than three and no longer than eight characters.

Examples

use icu::locid::extensions::unicode::Attribute;

let attr: Attribute = "buddhist".parse()
    .expect("Failed to parse an Attribute.");

assert_eq!(attr, "buddhist");

Implementations

impl Attribute[src]

pub fn from_bytes(v: &[u8]) -> Result<Self, ParserError>[src]

A constructor which takes a utf8 slice, parses it and produces a well-formed Attribute.

Examples

use icu::locid::extensions::unicode::Attribute;

let attribute = Attribute::from_bytes(b"foobar")
    .expect("Parsing failed.");

assert_eq!(attribute, "foobar");

Notice: No attribute subtags are defined by the current CLDR specification.

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

A helper function for displaying a Attribute subtag as a &str.

Examples

use icu::locid::extensions::unicode::Attribute;

let attribute = Attribute::from_bytes(b"foobar")
    .expect("Parsing failed.");

assert_eq!(attribute.as_str(), "foobar");

Notice: For many use cases, such as comparison, Attribute implements PartialEq<&str> which allows for direct comparisons.

Trait Implementations

impl Clone for Attribute[src]

impl Copy for Attribute[src]

impl Debug for Attribute[src]

impl Display for Attribute[src]

impl Eq for Attribute[src]

impl FromStr for Attribute[src]

type Err = ParserError

The associated error which can be returned from parsing.

impl Hash for Attribute[src]

impl Ord for Attribute[src]

impl PartialEq<&'_ str> for Attribute[src]

impl PartialEq<Attribute> for Attribute[src]

impl PartialOrd<Attribute> for Attribute[src]

impl StructuralEq for Attribute[src]

impl StructuralPartialEq for Attribute[src]

impl Writeable for Attribute[src]

Auto Trait Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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.