pub struct PropertyParser<T> { /* private fields */ }
Expand description
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§
Source§impl<T> PropertyParser<T>
impl<T> PropertyParser<T>
Sourcepub fn new() -> PropertyParserBorrowed<'static, T>where
T: ParseableEnumeratedProperty,
pub 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.
Sourcepub fn try_new_unstable(
provider: &(impl DataProvider<T::DataMarker> + ?Sized),
) -> Result<Self, DataError>where
T: ParseableEnumeratedProperty,
pub fn try_new_unstable(
provider: &(impl DataProvider<T::DataMarker> + ?Sized),
) -> Result<Self, DataError>where
T: ParseableEnumeratedProperty,
A version of Self::new
that uses custom data provided by a DataProvider
.
Sourcepub fn as_borrowed(&self) -> PropertyParserBorrowed<'_, T>
pub fn as_borrowed(&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.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for PropertyParser<T>
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> UnwindSafe for PropertyParser<T>
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes