Struct Attributes

struct Attributes(_)

A set of Attribute elements as defined in Unicode Extension Attributes.

Examples

use icu::locale::extensions::unicode::{Attribute, Attributes};

let attribute1: Attribute =
    "foobar".parse().expect("Failed to parse a variant subtag.");

let attribute2: Attribute = "testing"
    .parse()
    .expect("Failed to parse a variant subtag.");
let mut v = vec![attribute1, attribute2];
v.sort();
v.dedup();

let attributes: Attributes = Attributes::from_vec_unchecked(v);
assert_eq!(attributes.to_string(), "foobar-testing");

Implementations

impl Attributes

fn to_string(self: &Self) -> String

Converts the given value to a String.

Under the hood, this uses an efficient Writeable implementation. However, in order to avoid allocating a string, it is more efficient to use Writeable directly.

impl Attributes

const fn new() -> Self

Returns a new empty set of attributes. Same as default(), but is const.

Examples

use icu::locale::extensions::unicode::Attributes;

assert_eq!(Attributes::new(), Attributes::default());
fn clear(self: &mut Self) -> Self

Empties the Attributes list.

Returns the old list.

Examples

use icu::locale::extensions::unicode::{attribute, Attributes};
use writeable::assert_writeable_eq;

let mut attributes = Attributes::from_vec_unchecked(vec![
    attribute!("foobar"),
    attribute!("testing"),
]);

assert_writeable_eq!(attributes, "foobar-testing");

attributes.clear();

assert_writeable_eq!(attributes, "");

impl Clone for Attributes

fn clone(self: &Self) -> Attributes

impl Debug for Attributes

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Default for Attributes

fn default() -> Attributes

impl Deref for Attributes

fn deref(self: &Self) -> &[Attribute]

impl Display for Attributes

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Eq for Attributes

impl Freeze for Attributes

impl Hash for Attributes

fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)

impl Ord for Attributes

fn cmp(self: &Self, other: &Attributes) -> Ordering

impl PartialEq for Attributes

fn eq(self: &Self, other: &Attributes) -> bool

impl PartialOrd for Attributes

fn partial_cmp(self: &Self, other: &Attributes) -> Option<Ordering>

impl RefUnwindSafe for Attributes

impl Send for Attributes

impl StructuralPartialEq for Attributes

impl Sync for Attributes

impl Unpin for Attributes

impl UnsafeUnpin for Attributes

impl UnwindSafe for Attributes

impl Writeable for Attributes

fn write_to<W: core::fmt::Write + ?Sized>(self: &Self, sink: &mut W) -> Result
fn writeable_length_hint(self: &Self) -> LengthHint

impl<P, T> Receiver for Attributes

impl<T> Any for Attributes

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Attributes

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Attributes

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Attributes

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> ErasedDestructor for Attributes

impl<T> From for Attributes

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Attributes

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for Attributes

fn to_string(self: &Self) -> String

impl<T, U> Into for Attributes

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Attributes

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Attributes

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>