Struct icu::properties::script::ScriptWithExtensions

source ·
pub struct ScriptWithExtensions { /* private fields */ }
Expand description

A struct that represents the data for the Script and Script_Extensions properties.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

Most useful methods are on ScriptWithExtensionsBorrowed obtained by calling ScriptWithExtensions::as_borrowed()

§Examples

use icu::properties::script::ScriptWithExtensions;
use icu::properties::props::Script;
let swe = ScriptWithExtensions::new();

// get the `Script` property value
assert_eq!(swe.get_script_val('ـ'), Script::Common); // U+0640 ARABIC TATWEEL
assert_eq!(swe.get_script_val('\u{0650}'), Script::Inherited); // U+0650 ARABIC KASRA
assert_eq!(swe.get_script_val('٠'), Script::Arabic); // // U+0660 ARABIC-INDIC DIGIT ZERO
assert_eq!(swe.get_script_val('ﷲ'), Script::Arabic); // U+FDF2 ARABIC LIGATURE ALLAH ISOLATED FORM

// get the `Script_Extensions` property value
assert_eq!(
    swe.get_script_extensions_val('ـ') // U+0640 ARABIC TATWEEL
        .iter().collect::<Vec<_>>(),
    [Script::Arabic, Script::Syriac, Script::Mandaic, Script::Manichaean,
         Script::PsalterPahlavi, Script::Adlam, Script::HanifiRohingya, Script::Sogdian,
         Script::OldUyghur]
);
assert_eq!(
    swe.get_script_extensions_val('🥳') // U+1F973 FACE WITH PARTY HORN AND PARTY HAT
        .iter().collect::<Vec<_>>(),
    [Script::Common]
);
assert_eq!(
    swe.get_script_extensions_val('\u{200D}') // ZERO WIDTH JOINER
        .iter().collect::<Vec<_>>(),
    [Script::Inherited]
);
assert_eq!(
    swe.get_script_extensions_val('௫') // U+0BEB TAMIL DIGIT FIVE
        .iter().collect::<Vec<_>>(),
    [Script::Tamil, Script::Grantha]
);

// check containment of a `Script` value in the `Script_Extensions` value
// U+0650 ARABIC KASRA
assert!(!swe.has_script('\u{0650}', Script::Inherited)); // main Script value
assert!(swe.has_script('\u{0650}', Script::Arabic));
assert!(swe.has_script('\u{0650}', Script::Syriac));
assert!(!swe.has_script('\u{0650}', Script::Thaana));

// get a `CodePointInversionList` for when `Script` value is contained in `Script_Extensions` value
let syriac = swe.get_script_extensions_set(Script::Syriac);
assert!(syriac.contains('\u{0650}')); // ARABIC KASRA
assert!(!syriac.contains('٠')); // ARABIC-INDIC DIGIT ZERO
assert!(!syriac.contains('ﷲ')); // ARABIC LIGATURE ALLAH ISOLATED FORM
assert!(syriac.contains('܀')); // SYRIAC END OF PARAGRAPH
assert!(syriac.contains('\u{074A}')); // SYRIAC BARREKH

Implementations§

source§

impl ScriptWithExtensions

source

pub fn new() -> ScriptWithExtensionsBorrowed<'static>

Creates a new instance of ScriptWithExtensionsBorrowed using compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

pub fn try_new_with_any_provider( provider: &(impl AnyProvider + ?Sized), ) -> Result<ScriptWithExtensions, DataError>

A version of [Self :: new] that uses custom data provided by an AnyProvider.

📚 Help choosing a constructor

source

pub fn try_new_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), ) -> Result<ScriptWithExtensions, DataError>

A version of [Self :: new] that uses custom data provided by a BufferProvider.

Enabled with the serde feature.

📚 Help choosing a constructor

source

pub fn try_new_unstable( provider: &(impl DataProvider<ScriptWithExtensionsPropertyV1Marker> + ?Sized), ) -> Result<ScriptWithExtensions, DataError>

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.
source

pub fn as_borrowed(&self) -> ScriptWithExtensionsBorrowed<'_>

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

This avoids a potential small underlying cost per API call (ex: contains()) by consolidating it up front.

Trait Implementations§

source§

impl Debug for ScriptWithExtensions

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T
where T: Send + Sync,