Struct PropertyNamesShortBorrowed

struct PropertyNamesShortBorrowed<'a, T: NamedEnumeratedProperty> { ... }

A borrowed wrapper around property value name-to-enum data, returned by [PropertyNamesShort::as_borrowed()]. More efficient to query.

Implementations

impl PropertyNamesShortBorrowed<'_, Script>

fn get_locale_script(self: Self, property: Script) -> Option<Script>

Gets the "name" of a script property as a icu::locale::subtags::Script.

This method is available only on PropertyNamesShortBorrowed<Script>.

Example

use icu::locale::subtags::script;
use icu::properties::props::Script;
use icu::properties::PropertyNamesShort;

let lookup = PropertyNamesShort::<Script>::new();
assert_eq!(
    lookup.get_locale_script(Script::Brahmi),
    Some(script!("Brah"))
);
assert_eq!(
    lookup.get_locale_script(Script::Hangul),
    Some(script!("Hang"))
);

For the reverse direction, use property parsing as normal:

use icu::locale::subtags::script;
use icu::properties::props::Script;
use icu::properties::PropertyParser;

let parser = PropertyParser::<Script>::new();
assert_eq!(
    parser.get_strict(script!("Brah").as_str()),
    Some(Script::Brahmi)
);
assert_eq!(
    parser.get_strict(script!("Hang").as_str()),
    Some(Script::Hangul)
);

impl<'a, T: NamedEnumeratedProperty> PropertyNamesShortBorrowed<'a, T>

fn get(self: Self, property: T) -> Option<&'a str>

Get the property name given a value

Example

use icu::properties::props::CanonicalCombiningClass;
use icu::properties::PropertyNamesShort;

let lookup = PropertyNamesShort::<CanonicalCombiningClass>::new();
assert_eq!(lookup.get(CanonicalCombiningClass::KanaVoicing), Some("KV"));
assert_eq!(lookup.get(CanonicalCombiningClass::AboveLeft), Some("AL"));

impl<T: NamedEnumeratedProperty> PropertyNamesShortBorrowed<'static, T>

fn new() -> Self

Creates a new instance of PropertyNamesShortBorrowed<T>.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

fn static_to_owned(self: Self) -> PropertyNamesShort<T>

Cheaply converts a [PropertyNamesShortBorrowed<'static>] into a PropertyNamesShort.

Note: Due to branching and indirection, using PropertyNamesShort might inhibit some compile-time optimizations that are possible with PropertyNamesShortBorrowed.

This is currently not const unlike other static_to_owned() functions since it needs const traits to do that safely

impl<'a, T> Freeze for PropertyNamesShortBorrowed<'a, T>

impl<'a, T> RefUnwindSafe for PropertyNamesShortBorrowed<'a, T>

impl<'a, T> Send for PropertyNamesShortBorrowed<'a, T>

impl<'a, T> Sync for PropertyNamesShortBorrowed<'a, T>

impl<'a, T> Unpin for PropertyNamesShortBorrowed<'a, T>

impl<'a, T> UnsafeUnpin for PropertyNamesShortBorrowed<'a, T>

impl<'a, T> UnwindSafe for PropertyNamesShortBorrowed<'a, T>

impl<'a, T: $crate::fmt::Debug + NamedEnumeratedProperty> Debug for PropertyNamesShortBorrowed<'a, T>

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

impl<T> Any for PropertyNamesShortBorrowed<'a, T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for PropertyNamesShortBorrowed<'a, T>

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

impl<T> BorrowMut for PropertyNamesShortBorrowed<'a, T>

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

impl<T> CloneToUninit for PropertyNamesShortBorrowed<'a, T>

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

impl<T> ErasedDestructor for PropertyNamesShortBorrowed<'a, T>

impl<T> From for PropertyNamesShortBorrowed<'a, T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for PropertyNamesShortBorrowed<'a, T>

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

impl<T, U> Into for PropertyNamesShortBorrowed<'a, T>

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 PropertyNamesShortBorrowed<'a, T>

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

impl<T, U> TryInto for PropertyNamesShortBorrowed<'a, T>

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

impl<T: NamedEnumeratedProperty> Clone for PropertyNamesShortBorrowed<'_, T>

fn clone(self: &Self) -> Self

impl<T: NamedEnumeratedProperty> Copy for PropertyNamesShortBorrowed<'_, T>

impl<T: NamedEnumeratedProperty> Default for PropertyNamesShortBorrowed<'static, T>

fn default() -> Self