Struct ScriptWithExtensionsBorrowed

struct ScriptWithExtensionsBorrowed<'a> { ... }

A borrowed wrapper around script extension data, returned by [ScriptWithExtensions::as_borrowed()]. More efficient to query.

Implementations

impl ScriptWithExtensionsBorrowed<'static>

fn new() -> Self

Creates a new instance of ScriptWithExtensionsBorrowed using compiled data.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

const fn static_to_owned(self: Self) -> ScriptWithExtensions

Cheaply converts a [ScriptWithExtensionsBorrowed<'static>] into a ScriptWithExtensions.

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

impl<'a> ScriptWithExtensionsBorrowed<'a>

fn get_script_val(self: Self, ch: char) -> Script

Returns the Script property value for this code point.

Examples

use icu::properties::script::ScriptWithExtensions;
use icu::properties::props::Script;

let swe = ScriptWithExtensions::new();

// U+0640 ARABIC TATWEEL
assert_eq!(swe.get_script_val('ـ'), Script::Common); // main Script value
assert_ne!(swe.get_script_val('ـ'), Script::Arabic);
assert_ne!(swe.get_script_val('ـ'), Script::Syriac);
assert_ne!(swe.get_script_val('ـ'), Script::Thaana);

// U+0650 ARABIC KASRA
assert_eq!(swe.get_script_val('\u{0650}'), Script::Inherited); // main Script value
assert_ne!(swe.get_script_val('\u{0650}'), Script::Arabic);
assert_ne!(swe.get_script_val('\u{0650}'), Script::Syriac);
assert_ne!(swe.get_script_val('\u{0650}'), Script::Thaana);

// U+0660 ARABIC-INDIC DIGIT ZERO
assert_ne!(swe.get_script_val('٠'), Script::Common);
assert_eq!(swe.get_script_val('٠'), Script::Arabic); // main Script value
assert_ne!(swe.get_script_val('٠'), Script::Syriac);
assert_ne!(swe.get_script_val('٠'), Script::Thaana);

// U+FDF2 ARABIC LIGATURE ALLAH ISOLATED FORM
assert_ne!(swe.get_script_val(''), Script::Common);
assert_eq!(swe.get_script_val(''), Script::Arabic); // main Script value
assert_ne!(swe.get_script_val(''), Script::Syriac);
assert_ne!(swe.get_script_val(''), Script::Thaana);
fn get_script_val32(self: Self, code_point: u32) -> Script

See Self::get_script_val.

fn get_script_extensions_val(self: Self, ch: char) -> ScriptExtensionsSet<'a>

Return the Script_Extensions property value for this code point.

If code_point has Script_Extensions, then return the Script codes in the Script_Extensions. In this case, the Script property value (normally Common or Inherited) is not included in the ScriptExtensionsSet.

If c does not have Script_Extensions, then the one Script code is put into the ScriptExtensionsSet and also returned.

If c is not a valid code point, then return an empty ScriptExtensionsSet.

Examples

use icu::properties::script::ScriptWithExtensions;
use icu::properties::props::Script;

let swe = ScriptWithExtensions::new();

assert_eq!(
    swe.get_script_extensions_val('𐓐') // U+104D0 OSAGE CAPITAL LETTER KHA
        .iter()
        .collect::<Vec<_>>(),
    [Script::Osage]
);
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]
);
fn get_script_extensions_val32(self: Self, code_point: u32) -> ScriptExtensionsSet<'a>

See Self::get_script_extensions_val.

fn has_script(self: Self, ch: char, script: Script) -> bool

Returns whether script is contained in the Script_Extensions property value if the code_point has Script_Extensions, otherwise if the code point does not have Script_Extensions then returns whether the Script property value matches.

Some characters are commonly used in multiple scripts. For more information, see UAX #24: http://www.unicode.org/reports/tr24/.

Examples

use icu::properties::script::ScriptWithExtensions;
use icu::properties::props::Script;

let swe = ScriptWithExtensions::new();

// 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));

// U+0660 ARABIC-INDIC DIGIT ZERO
assert!(!swe.has_script('٠', Script::Common)); // main Script value
assert!(swe.has_script('٠', Script::Arabic));
assert!(!swe.has_script('٠', Script::Syriac));
assert!(swe.has_script('٠', Script::Thaana));

// U+FDF2 ARABIC LIGATURE ALLAH ISOLATED FORM
assert!(!swe.has_script('', Script::Common));
assert!(swe.has_script('', Script::Arabic)); // main Script value
assert!(!swe.has_script('', Script::Syriac));
assert!(swe.has_script('', Script::Thaana));
fn has_script32(self: Self, code_point: u32, script: Script) -> bool

See Self::has_script.

fn get_script_extensions_ranges(self: Self, script: Script) -> impl Iterator<Item = RangeInclusive<u32>> + 'a

Returns all of the matching CodePointMapRanges for the given Script in which has_script will return true for all of the contained code points.

Examples

use icu::properties::props::Script;
use icu::properties::script::ScriptWithExtensions;

let swe = ScriptWithExtensions::new();

let syriac_script_extensions_ranges =
    swe.get_script_extensions_ranges(Script::Syriac);

let exp_ranges = [
    0x0303..=0x0304, // COMBINING TILDE..COMBINING MACRON
    0x0307..=0x0308, // COMBINING DOT ABOVE..COMBINING DIAERESIS
    0x030A..=0x030A, // COMBINING RING ABOVE
    0x0320..=0x0320, // COMBINING MINUS SIGN BELOW
    0x0323..=0x0325, // COMBINING DOT BELOW..COMBINING RING BELOW
    0x032D..=0x032E, // COMBINING CIRCUMFLEX ACCENT BELOW..COMBINING BREVE BELOW
    0x0330..=0x0330, // COMBINING TILDE BELOW
    0x060C..=0x060C, // ARABIC COMMA
    0x061B..=0x061C, // ARABIC SEMICOLON, ARABIC LETTER MARK
    0x061F..=0x061F, // ARABIC QUESTION MARK
    0x0640..=0x0640, // ARABIC TATWEEL
    0x064B..=0x0655, // ARABIC FATHATAN..ARABIC HAMZA BELOW
    0x0670..=0x0670, // ARABIC LETTER SUPERSCRIPT ALEF
    0x0700..=0x070D, // Syriac block begins at U+0700
    0x070F..=0x074A, // Syriac block
    0x074D..=0x074F, // Syriac block ends at U+074F
    0x0860..=0x086A, // Syriac Supplement block is U+0860..=U+086F
    0x1DF8..=0x1DF8, // COMBINING DOT ABOVE LEFT
    0x1DFA..=0x1DFA, // COMBINING DOT BELOW LEFT
];

assert_eq!(
    syriac_script_extensions_ranges.collect::<Vec<_>>(),
    exp_ranges
);

impl Default for ScriptWithExtensionsBorrowed<'static>

fn default() -> Self

impl<'a> Clone for ScriptWithExtensionsBorrowed<'a>

fn clone(self: &Self) -> ScriptWithExtensionsBorrowed<'a>

impl<'a> Copy for ScriptWithExtensionsBorrowed<'a>

impl<'a> Debug for ScriptWithExtensionsBorrowed<'a>

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

impl<'a> Freeze for ScriptWithExtensionsBorrowed<'a>

impl<'a> RefUnwindSafe for ScriptWithExtensionsBorrowed<'a>

impl<'a> Send for ScriptWithExtensionsBorrowed<'a>

impl<'a> Sync for ScriptWithExtensionsBorrowed<'a>

impl<'a> Unpin for ScriptWithExtensionsBorrowed<'a>

impl<'a> UnsafeUnpin for ScriptWithExtensionsBorrowed<'a>

impl<'a> UnwindSafe for ScriptWithExtensionsBorrowed<'a>

impl<T> Any for ScriptWithExtensionsBorrowed<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for ScriptWithExtensionsBorrowed<'a>

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

impl<T> BorrowMut for ScriptWithExtensionsBorrowed<'a>

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

impl<T> CloneToUninit for ScriptWithExtensionsBorrowed<'a>

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

impl<T> ErasedDestructor for ScriptWithExtensionsBorrowed<'a>

impl<T> From for ScriptWithExtensionsBorrowed<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for ScriptWithExtensionsBorrowed<'a>

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

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

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 ScriptWithExtensionsBorrowed<'a>

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

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

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