Struct unicode_script::ScriptExtension

source ·
#[non_exhaustive]
pub struct ScriptExtension { /* private fields */ }
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

Implementations§

source§

impl ScriptExtension

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.