Struct unicode_script::ScriptExtension

source ·
#[non_exhaustive]
pub struct ScriptExtension { pub(crate) first: u64, pub(crate) second: u64, pub(crate) third: u64, pub(crate) common: bool, }
Expand description

A value for the Script_Extension property

ScriptExtension is one or more Script

This is essentially an optimized version of Vec<Script> that uses bitfields

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§first: u64§second: u64§third: u64§common: bool

Implementations§

source§

impl ScriptExtension

source

pub(crate) const THIRD_MAX: u64 = 1_099_511_627_775u64

source

pub(crate) const fn new(first: u64, second: u64, third: u64) -> Self

source

pub(crate) const fn new_common() -> Self

source

pub(crate) const fn new_inherited() -> Self

source

pub(crate) const fn new_unknown() -> Self

source

pub(crate) const fn is_common_or_inherited(self) -> bool

source

pub const fn is_common(self) -> bool

Checks if the script extension is Common

source

pub const fn is_inherited(self) -> bool

Checks if the script extension is Inherited

source

pub const fn is_empty(self) -> bool

Checks if the script extension is empty (unknown)

source

pub fn len(self) -> usize

Returns the number of scripts in the script extension

source

pub fn intersect_with(&mut self, other: Self)

Intersect this ScriptExtension with another ScriptExtension. Produces Unknown if things do not intersect. This is equivalent to ScriptExtension::intersection but it stores the result in self

“Common” (Zyyy) and “Inherited” (Zinh) are considered as intersecting everything, the intersection of Common and Inherited is Inherited

source

pub const fn intersection(self, other: Self) -> Self

Find the intersection between two ScriptExtensions. Returns Unknown if things do not intersect.

“Common” (Zyyy) and “Inherited” (Zinh) are considered as intersecting everything, the intersection of Common and Inherited is Inherited

source

pub const fn union(self, other: Self) -> Self

Find the union between two ScriptExtensions.

“Common” (Zyyy) and “Inherited” (Zinh) are considered as intersecting everything, the union of Common and Inherited is Common

source

pub fn contains_script(self, script: Script) -> bool

Check if this ScriptExtension contains the given script

Should be used with specific scripts only, this will return true if self is not Unknown and script is Common or Inherited

source

pub fn for_str(x: &str) -> Self

Get the intersection of script extensions of all characters in a string.

source

pub fn iter(self) -> ScriptIterator

Iterate over the scripts in this script extension

Will never yield Script::Unknown

Trait Implementations§

source§

impl Clone for ScriptExtension

source§

fn clone(&self) -> ScriptExtension

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ScriptExtension

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for ScriptExtension

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for ScriptExtension

source§

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

Formats the value using the given formatter. Read more
source§

impl From<&str> for ScriptExtension

source§

fn from(o: &str) -> Self

Converts to this type from the input type.
source§

impl From<Script> for ScriptExtension

source§

fn from(script: Script) -> Self

Converts to this type from the input type.
source§

impl From<char> for ScriptExtension

source§

fn from(o: char) -> Self

Converts to this type from the input type.
source§

impl Hash for ScriptExtension

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for ScriptExtension

source§

fn eq(&self, other: &ScriptExtension) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<ScriptExtension> for Script

source§

type Error = ()

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

fn try_from(ext: ScriptExtension) -> Result<Self, ()>

Performs the conversion.
source§

impl Copy for ScriptExtension

source§

impl Eq for ScriptExtension

source§

impl StructuralPartialEq for ScriptExtension

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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, 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.