Struct icu::properties::script::ScriptWithExtensionsBorrowed
source · pub struct ScriptWithExtensionsBorrowed<'a> { /* private fields */ }
Expand description
A borrowed wrapper around script extension data, returned by
ScriptWithExtensions::as_borrowed()
. More efficient to query.
Implementations§
source§impl<'a> ScriptWithExtensionsBorrowed<'a>
impl<'a> ScriptWithExtensionsBorrowed<'a>
sourcepub fn get_script_val(self, ch: char) -> Script
pub fn get_script_val(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);
sourcepub fn get_script_val32(self, code_point: u32) -> Script
pub fn get_script_val32(self, code_point: u32) -> Script
See Self::get_script_val
.
sourcepub fn get_script_extensions_val(self, ch: char) -> ScriptExtensionsSet<'a>
pub fn get_script_extensions_val(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]
);
sourcepub fn get_script_extensions_val32(
self,
code_point: u32,
) -> ScriptExtensionsSet<'a>
pub fn get_script_extensions_val32( self, code_point: u32, ) -> ScriptExtensionsSet<'a>
sourcepub fn has_script(self, ch: char, script: Script) -> bool
pub fn has_script(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));
sourcepub fn has_script32(self, code_point: u32, script: Script) -> bool
pub fn has_script32(self, code_point: u32, script: Script) -> bool
See Self::has_script
.
sourcepub fn get_script_extensions_ranges(
self,
script: Script,
) -> impl Iterator<Item = RangeInclusive<u32>> + 'a
pub fn get_script_extensions_ranges( self, script: Script, ) -> impl Iterator<Item = RangeInclusive<u32>> + 'a
Returns all of the matching CodePointMapRange
s for the given Script
in which has_script
will return true for all of the contained code points.
§Examples
use icu::properties::script::ScriptWithExtensions;
use icu::properties::props::Script;
let swe = ScriptWithExtensions::new();
let syriac_script_extensions_ranges = swe.get_script_extensions_ranges(Script::Syriac);
let exp_ranges = [
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, // U+1DF8 COMBINING DOT ABOVE LEFT
0x1DFA..=0x1DFA, // U+1DFA COMBINING DOT BELOW LEFT
];
assert_eq!(syriac_script_extensions_ranges.collect::<Vec<_>>(), exp_ranges);
sourcepub fn get_script_extensions_set(
self,
script: Script,
) -> CodePointInversionList<'a>
pub fn get_script_extensions_set( self, script: Script, ) -> CodePointInversionList<'a>
Returns a CodePointInversionList
for the given Script
which represents all
code points for which has_script
will return true.
§Examples
use icu::properties::script::ScriptWithExtensions;
use icu::properties::props::Script;
let swe = ScriptWithExtensions::new();
let syriac = swe.get_script_extensions_set(Script::Syriac);
assert!(!syriac.contains('؞')); // ARABIC TRIPLE DOT PUNCTUATION MARK
assert!(syriac.contains('؟')); // ARABIC QUESTION MARK
assert!(!syriac.contains('ؠ')); // ARABIC LETTER KASHMIRI YEH
assert!(syriac.contains('܀')); // SYRIAC END OF PARAGRAPH
assert!(syriac.contains('\u{074A}')); // SYRIAC BARREKH
assert!(!syriac.contains('\u{074B}')); // unassigned
assert!(syriac.contains('ݏ')); // SYRIAC LETTER SOGDIAN FE
assert!(!syriac.contains('ݐ')); // ARABIC LETTER BEH WITH THREE DOTS HORIZONTALLY BELOW
assert!(syriac.contains('\u{1DF8}')); // COMBINING DOT ABOVE LEFT
assert!(!syriac.contains('\u{1DF9}')); // COMBINING WIDE INVERTED BRIDGE BELOW
assert!(syriac.contains('\u{1DFA}')); // COMBINING DOT BELOW LEFT
assert!(!syriac.contains('\u{1DFB}')); // COMBINING DELETION MARK
source§impl ScriptWithExtensionsBorrowed<'static>
impl ScriptWithExtensionsBorrowed<'static>
sourcepub fn new() -> ScriptWithExtensionsBorrowed<'static>
pub fn new() -> ScriptWithExtensionsBorrowed<'static>
Creates a new instance of ScriptWithExtensionsBorrowed
using compiled data.
✨ Enabled with the compiled_data
Cargo feature.
sourcepub const fn static_to_owned(self) -> ScriptWithExtensions
pub const fn static_to_owned(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
.
Trait Implementations§
source§impl<'a> Clone for ScriptWithExtensionsBorrowed<'a>
impl<'a> Clone for ScriptWithExtensionsBorrowed<'a>
source§fn clone(&self) -> ScriptWithExtensionsBorrowed<'a>
fn clone(&self) -> ScriptWithExtensionsBorrowed<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for ScriptWithExtensionsBorrowed<'a>
impl<'a> Debug for ScriptWithExtensionsBorrowed<'a>
source§impl Default for ScriptWithExtensionsBorrowed<'static>
impl Default for ScriptWithExtensionsBorrowed<'static>
source§fn default() -> ScriptWithExtensionsBorrowed<'static>
fn default() -> ScriptWithExtensionsBorrowed<'static>
impl<'a> Copy for ScriptWithExtensionsBorrowed<'a>
Auto Trait Implementations§
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> UnwindSafe for ScriptWithExtensionsBorrowed<'a>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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