Struct PropertyParser

struct PropertyParser<T> { ... }

A struct capable of looking up a property value from a string name. Access its data by calling [Self::as_borrowed()] and using the methods on PropertyParserBorrowed.

The name can be a short name (Lu), a long name(Uppercase_Letter), or an alias.

Property names can be looked up using "strict" matching (looking for a name that matches exactly), or "loose matching", where the name is allowed to deviate in terms of ASCII casing, whitespace, underscores, and hyphens.

Example

use icu::properties::props::GeneralCategory;
use icu::properties::PropertyParser;

let lookup = PropertyParser::<GeneralCategory>::new();
// short name for value
assert_eq!(
    lookup.get_strict("Lu"),
    Some(GeneralCategory::UppercaseLetter)
);
assert_eq!(
    lookup.get_strict("Pd"),
    Some(GeneralCategory::DashPunctuation)
);
// long name for value
assert_eq!(
    lookup.get_strict("Uppercase_Letter"),
    Some(GeneralCategory::UppercaseLetter)
);
assert_eq!(
    lookup.get_strict("Dash_Punctuation"),
    Some(GeneralCategory::DashPunctuation)
);
// name has incorrect casing
assert_eq!(lookup.get_strict("dashpunctuation"), None);
// loose matching of name
assert_eq!(
    lookup.get_loose("dash-punctuation"),
    Some(GeneralCategory::DashPunctuation)
);
// fake property
assert_eq!(lookup.get_strict("Animated_Gif"), None);

Implementations

impl<T> PropertyParser<T>

fn new() -> PropertyParserBorrowed<'static, T>
where
    T: ParseableEnumeratedProperty

Creates a new instance of PropertyParser<T> using compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

fn try_new_unstable<impl DataProvider<T::DataMarker> + ?Sized: DataProvider<<T as >::DataMarker> + ?Sized>(provider: &impl DataProvider<<T as >::DataMarker> + ?Sized) -> Result<Self, DataError>
where
    T: ParseableEnumeratedProperty

A version of Self::new that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
fn as_borrowed(self: &Self) -> PropertyParserBorrowed<'_, T>

Construct a borrowed version of this type that can be queried.

This avoids a potential small underlying cost per API call (like get_strict()) by consolidating it up front.

impl<T> Any for PropertyParser<T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for PropertyParser<T>

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

impl<T> BorrowMut for PropertyParser<T>

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

impl<T> ErasedDestructor for PropertyParser<T>

impl<T> Freeze for PropertyParser<T>

impl<T> From for PropertyParser<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> RefUnwindSafe for PropertyParser<T>

impl<T> Send for PropertyParser<T>

impl<T> Sync for PropertyParser<T>

impl<T> Unpin for PropertyParser<T>

impl<T> UnsafeUnpin for PropertyParser<T>

impl<T> UnwindSafe for PropertyParser<T>

impl<T, U> Into for PropertyParser<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 PropertyParser<T>

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

impl<T, U> TryInto for PropertyParser<T>

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

impl<T: $crate::fmt::Debug> Debug for PropertyParser<T>

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