[−][src]Struct unic_locale_impl::extensions::UnicodeExtensionList
A list of Unicode BCP47 U Extensions
as defined in Unicode Locale Identifier
specification.
Unicode extensions provide subtags that specify language and/or locale-based behavior
or refinements to language tags, according to work done by the Unicode Consortium.
(See RFC 6067
for details).
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "de-u-hc-h12-ca-buddhist".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.unicode.keyword("ca") .expect("Getting keyword failed.") .collect::<Vec<_>>(), &["buddhist"]);
Methods
impl UnicodeExtensionList
[src]
pub fn is_empty(&self) -> bool
[src]
Returns true
if there are no keywords and no attributes in
the UnicodeExtensionList
.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-u-foo".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.unicode.is_empty(), false);
pub fn keyword<S: AsRef<[u8]>>(
&self,
key: S
) -> Result<impl ExactSizeIterator<Item = &str>, LocaleError>
[src]
&self,
key: S
) -> Result<impl ExactSizeIterator<Item = &str>, LocaleError>
Returns the value of keyword in the UnicodeExtensionList
.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-u-ca-buddhist".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.unicode.keyword("ca") .expect("Getting keyword failed.") .collect::<Vec<_>>(), &["buddhist"]); // Here keyword with key "aa" is not available assert_eq!(loc.extensions.unicode.keyword("aa") .expect("Getting keyword failed.") .len(), 0);
pub fn keyword_keys(&self) -> impl ExactSizeIterator<Item = &str>
[src]
Returns an iterator over all keys in the UnicodeExtensionList
.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-u-ca-buddhist-nu-thai".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.unicode.keyword_keys().collect::<Vec<_>>(), &["ca", "nu"]);
pub fn set_keyword<S: AsRef<[u8]>>(
&mut self,
key: S,
value: &[S]
) -> Result<(), LocaleError>
[src]
&mut self,
key: S,
value: &[S]
) -> Result<(), LocaleError>
Adds a keyword to the UnicodeExtensionList
or sets value for key if
keyword is already included in the UnicodeExtensionList
.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US".parse() .expect("Parsing failed."); loc.extensions.unicode.set_keyword("ca", &["buddhist"]) .expect("Setting keyword failed."); assert_eq!(loc.to_string(), "en-US-u-ca-buddhist"); loc.extensions.unicode.set_keyword("ca", &["chinese"]) .expect("Setting keyword failed."); assert_eq!(loc.to_string(), "en-US-u-ca-chinese");
pub fn remove_keyword<S: AsRef<[u8]>>(
&mut self,
key: S
) -> Result<bool, LocaleError>
[src]
&mut self,
key: S
) -> Result<bool, LocaleError>
Removes a keyword from the UnicodeExtensionList
.
Returns true
if keyword was included in the UnicodeExtensionList
before removal.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-u-ca-buddhist".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.unicode.remove_keyword("ca") .expect("Removing tag failed."), true); assert_eq!(loc.to_string(), "en-US");
pub fn clear_keywords(&mut self)
[src]
Clears all keywords from the UnicodeExtensionList
.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-u-ca-buddhist".parse() .expect("Parsing failed."); loc.extensions.unicode.clear_keywords(); assert_eq!(loc.to_string(), "en-US");
pub fn has_attribute<S: AsRef<[u8]>>(
&self,
attribute: S
) -> Result<bool, LocaleError>
[src]
&self,
attribute: S
) -> Result<bool, LocaleError>
Returns true
if attribute is included in the UnicodeExtensionList
.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-u-foo".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.unicode.has_attribute("foo") .expect("Getting attribute failed."), true);
pub fn attributes(&self) -> impl ExactSizeIterator<Item = &str>
[src]
Returns an iterator over all attributes in the UnicodeExtensionList
.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-u-foo-bar".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.unicode.attributes().collect::<Vec<_>>(), &["bar", "foo"]);
pub fn set_attribute<S: AsRef<[u8]>>(
&mut self,
attribute: S
) -> Result<(), LocaleError>
[src]
&mut self,
attribute: S
) -> Result<(), LocaleError>
Sets an attribute on the UnicodeExtensionList
.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US".parse() .expect("Parsing failed."); loc.extensions.unicode.set_attribute("foo") .expect("Setting attribute failed."); assert_eq!(loc.to_string(), "en-US-u-foo");
pub fn remove_attribute<S: AsRef<[u8]>>(
&mut self,
attribute: S
) -> Result<bool, LocaleError>
[src]
&mut self,
attribute: S
) -> Result<bool, LocaleError>
Removes an attribute from the UnicodeExtensionList
.
Returns true
if attribute was included in the UnicodeExtensionList
before removal.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-u-foo".parse() .expect("Parsing failed."); assert_eq!(loc.extensions.unicode.remove_attribute("foo") .expect("Removing attribute failed."), true); assert_eq!(loc.to_string(), "en-US");
pub fn clear_attributes(&mut self)
[src]
Clears all attributes from the UnicodeExtensionList
.
Examples
use unic_locale_impl::Locale; let mut loc: Locale = "en-US-u-foo".parse() .expect("Parsing failed."); loc.extensions.unicode.clear_attributes(); assert_eq!(loc.to_string(), "en-US");
Trait Implementations
impl Clone for UnicodeExtensionList
[src]
fn clone(&self) -> UnicodeExtensionList
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for UnicodeExtensionList
[src]
impl Default for UnicodeExtensionList
[src]
fn default() -> UnicodeExtensionList
[src]
impl Display for UnicodeExtensionList
[src]
impl Eq for UnicodeExtensionList
[src]
impl Hash for UnicodeExtensionList
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for UnicodeExtensionList
[src]
fn cmp(&self, other: &UnicodeExtensionList) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<UnicodeExtensionList> for UnicodeExtensionList
[src]
fn eq(&self, other: &UnicodeExtensionList) -> bool
[src]
fn ne(&self, other: &UnicodeExtensionList) -> bool
[src]
impl PartialOrd<UnicodeExtensionList> for UnicodeExtensionList
[src]
fn partial_cmp(&self, other: &UnicodeExtensionList) -> Option<Ordering>
[src]
fn lt(&self, other: &UnicodeExtensionList) -> bool
[src]
fn le(&self, other: &UnicodeExtensionList) -> bool
[src]
fn gt(&self, other: &UnicodeExtensionList) -> bool
[src]
fn ge(&self, other: &UnicodeExtensionList) -> bool
[src]
impl StructuralEq for UnicodeExtensionList
[src]
impl StructuralPartialEq for UnicodeExtensionList
[src]
Auto Trait Implementations
impl RefUnwindSafe for UnicodeExtensionList
impl Send for UnicodeExtensionList
impl Sync for UnicodeExtensionList
impl Unpin for UnicodeExtensionList
impl UnwindSafe for UnicodeExtensionList
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,