Struct unic_locale_impl::extensions::PrivateExtensionList
source · pub struct PrivateExtensionList(/* private fields */);
Expand description
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");
Implementations§
source§impl PrivateExtensionList
impl PrivateExtensionList
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
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);
sourcepub fn has_tag<S: AsRef<[u8]>>(&self, tag: S) -> Result<bool, LocaleError>
pub fn has_tag<S: AsRef<[u8]>>(&self, tag: S) -> Result<bool, LocaleError>
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);
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"]);
sourcepub fn add_tag<S: AsRef<[u8]>>(&mut self, tag: S) -> Result<(), LocaleError>
pub fn add_tag<S: AsRef<[u8]>>(&mut self, tag: S) -> Result<(), LocaleError>
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");
sourcepub fn remove_tag<S: AsRef<[u8]>>(
&mut self,
tag: S
) -> Result<bool, LocaleError>
pub fn remove_tag<S: AsRef<[u8]>>( &mut self, tag: S ) -> Result<bool, LocaleError>
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");
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§
source§impl Clone for PrivateExtensionList
impl Clone for PrivateExtensionList
source§fn clone(&self) -> PrivateExtensionList
fn clone(&self) -> PrivateExtensionList
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PrivateExtensionList
impl Debug for PrivateExtensionList
source§impl Default for PrivateExtensionList
impl Default for PrivateExtensionList
source§fn default() -> PrivateExtensionList
fn default() -> PrivateExtensionList
Returns the “default value” for a type. Read more
source§impl Display for PrivateExtensionList
impl Display for PrivateExtensionList
source§impl Hash for PrivateExtensionList
impl Hash for PrivateExtensionList
source§impl Ord for PrivateExtensionList
impl Ord for PrivateExtensionList
source§fn cmp(&self, other: &PrivateExtensionList) -> Ordering
fn cmp(&self, other: &PrivateExtensionList) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for PrivateExtensionList
impl PartialEq for PrivateExtensionList
source§fn eq(&self, other: &PrivateExtensionList) -> bool
fn eq(&self, other: &PrivateExtensionList) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for PrivateExtensionList
impl PartialOrd for PrivateExtensionList
source§fn partial_cmp(&self, other: &PrivateExtensionList) -> Option<Ordering>
fn partial_cmp(&self, other: &PrivateExtensionList) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for PrivateExtensionList
impl StructuralPartialEq for PrivateExtensionList
Auto Trait Implementations§
impl Freeze for PrivateExtensionList
impl RefUnwindSafe for PrivateExtensionList
impl Send for PrivateExtensionList
impl Sync for PrivateExtensionList
impl Unpin for PrivateExtensionList
impl UnwindSafe for PrivateExtensionList
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more