[][src]Struct unic_locale_impl::extensions::PrivateExtensionList

pub struct PrivateExtensionList(_);

A list of Unicode Private Extensions as defined in Unicode Locale Identifier specification.

Those extensions are intended for pass-through use.

Examples

use unic_locale_impl::Locale;

let mut loc: Locale = "en-US-x-foo-faa".parse()
    .expect("Parsing failed.");

assert_eq!(loc.extensions.private.has_tag("faa"), Ok(true));
assert_eq!(loc.extensions.private.tags().next(), Some("faa")); // tags got sorted
loc.extensions.private.clear_tags();
assert_eq!(loc.to_string(), "en-US");

Methods

impl PrivateExtensionList[src]

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

Returns true if there are no tags in the PrivateExtensionList`.

Examples

use unic_locale_impl::Locale;

let mut loc: Locale = "en-US-x-foo".parse()
    .expect("Parsing failed.");

assert_eq!(loc.extensions.private.is_empty(), false);

pub fn has_tag<S: AsRef<[u8]>>(&self, tag: S) -> Result<bool, LocaleError>[src]

Returns true if tag is included in the PrivateExtensionList.

Examples

use unic_locale_impl::Locale;

let mut loc: Locale = "en-US-x-foo".parse()
    .expect("Parsing failed.");

assert_eq!(loc.extensions.private.has_tag("foo")
              .expect("Getting tag failed."),
           true);

pub fn tags(&self) -> impl ExactSizeIterator<Item = &str>[src]

Returns an iterator over all tags in the PrivateExtensionList.

Examples

use unic_locale_impl::Locale;

let mut loc: Locale = "en-US-x-foo-bar".parse()
    .expect("Parsing failed.");

assert_eq!(loc.extensions.private.tags().collect::<Vec<_>>(),
           &["bar", "foo"]);

pub fn add_tag<S: AsRef<[u8]>>(&mut self, tag: S) -> Result<(), LocaleError>[src]

Adds a tag to the PrivateExtensionList.

Examples

use unic_locale_impl::Locale;

let mut loc: Locale = "en-US".parse()
    .expect("Parsing failed.");

loc.extensions.private.add_tag("foo")
    .expect("Adding tag failed.");

assert_eq!(loc.to_string(), "en-US-x-foo");

pub fn remove_tag<S: AsRef<[u8]>>(
    &mut self,
    tag: S
) -> Result<bool, LocaleError>
[src]

Removes a tag from the PrivateExtensionList.

Returns true if tag was included in the PrivateExtensionList before removal.

Examples

use unic_locale_impl::Locale;

let mut loc: Locale = "en-US-x-foo".parse()
    .expect("Parsing failed.");

assert_eq!(loc.extensions.private.remove_tag("foo")
              .expect("Removing tag failed."),
           true);

assert_eq!(loc.to_string(), "en-US");

pub fn clear_tags(&mut self)[src]

Clears all tags from the PrivateExtensionList.

Examples

use unic_locale_impl::Locale;

let mut loc: Locale = "en-US-x-foo".parse()
    .expect("Parsing failed.");

loc.extensions.private.clear_tags();
assert_eq!(loc.to_string(), "en-US");

Trait Implementations

impl Clone for PrivateExtensionList[src]

impl Debug for PrivateExtensionList[src]

impl Default for PrivateExtensionList[src]

impl Display for PrivateExtensionList[src]

impl Eq for PrivateExtensionList[src]

impl Hash for PrivateExtensionList[src]

impl Ord for PrivateExtensionList[src]

impl PartialEq<PrivateExtensionList> for PrivateExtensionList[src]

impl PartialOrd<PrivateExtensionList> for PrivateExtensionList[src]

impl StructuralEq for PrivateExtensionList[src]

impl StructuralPartialEq for PrivateExtensionList[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.