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

pub struct Key(_);

A key used in a list of Keywords.

The key has to be a two ASCII alphanumerical characters long, with the first character being alphanumeric, and the second being alphabetic.

Examples

use icu::locid::extensions::unicode::Key;

let key1: Key = "ca".parse()
    .expect("Failed to parse a Key.");

assert_eq!(key1, "ca");

Implementations

impl Key[src]

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

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

Examples

use icu::locid::extensions::unicode::Key;

let key = Key::from_bytes(b"ca")
    .expect("Parsing failed.");

assert_eq!(key, "ca");

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

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

Examples

use icu::locid::extensions::unicode::Key;

let key: Key = "ca".parse().expect("Parsing failed.");

assert_eq!(key.as_str(), "ca");

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

Trait Implementations

impl Clone for Key[src]

impl Copy for Key[src]

impl Debug for Key[src]

impl Display for Key[src]

impl Eq for Key[src]

impl FromStr for Key[src]

type Err = ParserError

The associated error which can be returned from parsing.

impl Hash for Key[src]

impl Ord for Key[src]

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

impl PartialEq<Key> for Key[src]

impl PartialOrd<Key> for Key[src]

impl StructuralEq for Key[src]

impl StructuralPartialEq for Key[src]

impl Writeable for Key[src]

Auto Trait Implementations

impl RefUnwindSafe for Key

impl Send for Key

impl Sync for Key

impl Unpin for Key

impl UnwindSafe for Key

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.