Struct GeneralCategoryGroup

struct GeneralCategoryGroup(_)

Groupings of multiple General_Category property values.

Instances of GeneralCategoryGroup represent the defined multi-category values that are useful for users in certain contexts, such as regex. In other words, unlike GeneralCategory, this supports groups of general categories: for example, Letter /// is the union of UppercaseLetter, LowercaseLetter, etc.

See https://www.unicode.org/reports/tr44/ .

The discriminants correspond to the U_GC_XX_MASK constants in ICU4C. Unlike GeneralCategory, this supports groups of general categories: for example, Letter is the union of UppercaseLetter, LowercaseLetter, etc.

See UCharCategory and U_GET_GC_MASK in ICU4C.

Implementations

impl GeneralCategoryGroup

const fn contains(self: Self, val: GeneralCategory) -> bool

Return whether the code point belongs in the provided multi-value category.

use icu::properties::props::{GeneralCategory, GeneralCategoryGroup};
use icu::properties::CodePointMapData;

let gc = CodePointMapData::<GeneralCategory>::new();

assert_eq!(gc.get('A'), GeneralCategory::UppercaseLetter);
assert!(GeneralCategoryGroup::CasedLetter.contains(gc.get('A')));

// U+0B1E ORIYA LETTER NYA
assert_eq!(gc.get(''), GeneralCategory::OtherLetter);
assert!(GeneralCategoryGroup::Letter.contains(gc.get('')));
assert!(!GeneralCategoryGroup::CasedLetter.contains(gc.get('')));

// U+0301 COMBINING ACUTE ACCENT
assert_eq!(gc.get('\u{0301}'), GeneralCategory::NonspacingMark);
assert!(GeneralCategoryGroup::Mark.contains(gc.get('\u{0301}')));
assert!(!GeneralCategoryGroup::Letter.contains(gc.get('\u{0301}')));

assert_eq!(gc.get('0'), GeneralCategory::DecimalNumber);
assert!(GeneralCategoryGroup::Number.contains(gc.get('0')));
assert!(!GeneralCategoryGroup::Mark.contains(gc.get('0')));

assert_eq!(gc.get('('), GeneralCategory::OpenPunctuation);
assert!(GeneralCategoryGroup::Punctuation.contains(gc.get('(')));
assert!(!GeneralCategoryGroup::Number.contains(gc.get('(')));

// U+2713 CHECK MARK
assert_eq!(gc.get(''), GeneralCategory::OtherSymbol);
assert!(GeneralCategoryGroup::Symbol.contains(gc.get('')));
assert!(!GeneralCategoryGroup::Punctuation.contains(gc.get('')));

assert_eq!(gc.get(' '), GeneralCategory::SpaceSeparator);
assert!(GeneralCategoryGroup::Separator.contains(gc.get(' ')));
assert!(!GeneralCategoryGroup::Symbol.contains(gc.get(' ')));

// U+E007F CANCEL TAG
assert_eq!(gc.get('\u{E007F}'), GeneralCategory::Format);
assert!(GeneralCategoryGroup::Other.contains(gc.get('\u{E007F}')));
assert!(!GeneralCategoryGroup::Separator.contains(gc.get('\u{E007F}')));
const fn complement(self: Self) -> Self

Produce a GeneralCategoryGroup that is the inverse of this one

Example

use icu::properties::props::{GeneralCategory, GeneralCategoryGroup};

let letter = GeneralCategoryGroup::Letter;
let not_letter = letter.complement();

assert!(not_letter.contains(GeneralCategory::MathSymbol));
assert!(!letter.contains(GeneralCategory::MathSymbol));
assert!(not_letter.contains(GeneralCategory::OtherPunctuation));
assert!(!letter.contains(GeneralCategory::OtherPunctuation));
assert!(!not_letter.contains(GeneralCategory::UppercaseLetter));
assert!(letter.contains(GeneralCategory::UppercaseLetter));
const fn all() -> Self

Return the group representing all GeneralCategory values

Example

use icu::properties::props::{GeneralCategory, GeneralCategoryGroup};

let all = GeneralCategoryGroup::all();

assert!(all.contains(GeneralCategory::MathSymbol));
assert!(all.contains(GeneralCategory::OtherPunctuation));
assert!(all.contains(GeneralCategory::UppercaseLetter));
const fn empty() -> Self

Return the empty group

Example

use icu::properties::props::{GeneralCategory, GeneralCategoryGroup};

let empty = GeneralCategoryGroup::empty();

assert!(!empty.contains(GeneralCategory::MathSymbol));
assert!(!empty.contains(GeneralCategory::OtherPunctuation));
assert!(!empty.contains(GeneralCategory::UppercaseLetter));
const fn union(self: Self, other: Self) -> Self

Take the union of two groups

Example

use icu::properties::props::{GeneralCategory, GeneralCategoryGroup};

let letter = GeneralCategoryGroup::Letter;
let symbol = GeneralCategoryGroup::Symbol;
let union = letter.union(symbol);

assert!(union.contains(GeneralCategory::MathSymbol));
assert!(!union.contains(GeneralCategory::OtherPunctuation));
assert!(union.contains(GeneralCategory::UppercaseLetter));
const fn intersection(self: Self, other: Self) -> Self

Take the intersection of two groups

Example

use icu::properties::props::{GeneralCategory, GeneralCategoryGroup};

let letter = GeneralCategoryGroup::Letter;
let lu = GeneralCategoryGroup::UppercaseLetter;
let intersection = letter.intersection(lu);

assert!(!intersection.contains(GeneralCategory::MathSymbol));
assert!(!intersection.contains(GeneralCategory::OtherPunctuation));
assert!(intersection.contains(GeneralCategory::UppercaseLetter));
assert!(!intersection.contains(GeneralCategory::LowercaseLetter));

impl AsULE for GeneralCategoryGroup

fn to_unaligned(self: Self) -> <Self as >::ULE
fn from_unaligned(ule: <Self as >::ULE) -> Self

impl Clone for GeneralCategoryGroup

fn clone(self: &Self) -> GeneralCategoryGroup

impl Copy for GeneralCategoryGroup

impl Debug for GeneralCategoryGroup

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

impl Eq for GeneralCategoryGroup

impl Freeze for GeneralCategoryGroup

impl From for GeneralCategoryGroup

fn from(subcategory: GeneralCategory) -> Self

impl From for GeneralCategoryGroup

fn from(mask: u32) -> Self

impl ParseableEnumeratedProperty for GeneralCategoryGroup

impl PartialEq for GeneralCategoryGroup

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

impl RefUnwindSafe for GeneralCategoryGroup

impl Send for GeneralCategoryGroup

impl StructuralPartialEq for GeneralCategoryGroup

impl Sync for GeneralCategoryGroup

impl TrieValue for GeneralCategoryGroup

fn try_from_u32(i: u32) -> Result<Self, <Self as >::TryFromU32Error>
fn to_u32(self: Self) -> u32

impl Unpin for GeneralCategoryGroup

impl UnsafeUnpin for GeneralCategoryGroup

impl UnwindSafe for GeneralCategoryGroup

impl<T> Any for GeneralCategoryGroup

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for GeneralCategoryGroup

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

impl<T> BorrowMut for GeneralCategoryGroup

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

impl<T> CloneToUninit for GeneralCategoryGroup

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

impl<T> ErasedDestructor for GeneralCategoryGroup

impl<T> From for GeneralCategoryGroup

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for GeneralCategoryGroup

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

impl<T, U> Into for GeneralCategoryGroup

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 GeneralCategoryGroup

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

impl<T, U> TryInto for GeneralCategoryGroup

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