Struct icu::properties::props::GeneralCategoryGroup
source · pub struct GeneralCategoryGroup(/* private fields */);
Expand description
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§
source§impl GeneralCategoryGroup
impl GeneralCategoryGroup
sourcepub const UppercaseLetter: GeneralCategoryGroup = _
pub const UppercaseLetter: GeneralCategoryGroup = _
(Lu
) An uppercase letter
sourcepub const LowercaseLetter: GeneralCategoryGroup = _
pub const LowercaseLetter: GeneralCategoryGroup = _
(Ll
) A lowercase letter
sourcepub const TitlecaseLetter: GeneralCategoryGroup = _
pub const TitlecaseLetter: GeneralCategoryGroup = _
(Lt
) A digraphic letter, with first part uppercase
sourcepub const ModifierLetter: GeneralCategoryGroup = _
pub const ModifierLetter: GeneralCategoryGroup = _
(Lm
) A modifier letter
sourcepub const OtherLetter: GeneralCategoryGroup = _
pub const OtherLetter: GeneralCategoryGroup = _
(Lo
) Other letters, including syllables and ideographs
sourcepub const CasedLetter: GeneralCategoryGroup = _
pub const CasedLetter: GeneralCategoryGroup = _
(LC
) The union of UppercaseLetter, LowercaseLetter, and TitlecaseLetter
sourcepub const Letter: GeneralCategoryGroup = _
pub const Letter: GeneralCategoryGroup = _
(L
) The union of all letter categories
sourcepub const NonspacingMark: GeneralCategoryGroup = _
pub const NonspacingMark: GeneralCategoryGroup = _
(Mn
) A nonspacing combining mark (zero advance width)
sourcepub const EnclosingMark: GeneralCategoryGroup = _
pub const EnclosingMark: GeneralCategoryGroup = _
(Mc
) A spacing combining mark (positive advance width)
sourcepub const SpacingMark: GeneralCategoryGroup = _
pub const SpacingMark: GeneralCategoryGroup = _
(Me
) An enclosing combining mark
sourcepub const Mark: GeneralCategoryGroup = _
pub const Mark: GeneralCategoryGroup = _
(M
) The union of all mark categories
sourcepub const DecimalNumber: GeneralCategoryGroup = _
pub const DecimalNumber: GeneralCategoryGroup = _
(Nd
) A decimal digit
sourcepub const LetterNumber: GeneralCategoryGroup = _
pub const LetterNumber: GeneralCategoryGroup = _
(Nl
) A letterlike numeric character
sourcepub const OtherNumber: GeneralCategoryGroup = _
pub const OtherNumber: GeneralCategoryGroup = _
(No
) A numeric character of other type
sourcepub const Number: GeneralCategoryGroup = _
pub const Number: GeneralCategoryGroup = _
(N
) The union of all number categories
sourcepub const SpaceSeparator: GeneralCategoryGroup = _
pub const SpaceSeparator: GeneralCategoryGroup = _
(Zs
) A space character (of various non-zero widths)
sourcepub const LineSeparator: GeneralCategoryGroup = _
pub const LineSeparator: GeneralCategoryGroup = _
(Zl
) U+2028 LINE SEPARATOR only
sourcepub const ParagraphSeparator: GeneralCategoryGroup = _
pub const ParagraphSeparator: GeneralCategoryGroup = _
(Zp
) U+2029 PARAGRAPH SEPARATOR only
sourcepub const Separator: GeneralCategoryGroup = _
pub const Separator: GeneralCategoryGroup = _
(Z
) The union of all separator categories
sourcepub const Control: GeneralCategoryGroup = _
pub const Control: GeneralCategoryGroup = _
(Cc
) A C0 or C1 control code
sourcepub const Format: GeneralCategoryGroup = _
pub const Format: GeneralCategoryGroup = _
(Cf
) A format control character
sourcepub const PrivateUse: GeneralCategoryGroup = _
pub const PrivateUse: GeneralCategoryGroup = _
(Co
) A private-use character
sourcepub const Surrogate: GeneralCategoryGroup = _
pub const Surrogate: GeneralCategoryGroup = _
(Cs
) A surrogate code point
sourcepub const Unassigned: GeneralCategoryGroup = _
pub const Unassigned: GeneralCategoryGroup = _
(Cn
) A reserved unassigned code point or a noncharacter
sourcepub const Other: GeneralCategoryGroup = _
pub const Other: GeneralCategoryGroup = _
(C
) The union of all control code, reserved, and unassigned categories
sourcepub const DashPunctuation: GeneralCategoryGroup = _
pub const DashPunctuation: GeneralCategoryGroup = _
(Pd
) A dash or hyphen punctuation mark
sourcepub const OpenPunctuation: GeneralCategoryGroup = _
pub const OpenPunctuation: GeneralCategoryGroup = _
(Ps
) An opening punctuation mark (of a pair)
sourcepub const ClosePunctuation: GeneralCategoryGroup = _
pub const ClosePunctuation: GeneralCategoryGroup = _
(Pe
) A closing punctuation mark (of a pair)
sourcepub const ConnectorPunctuation: GeneralCategoryGroup = _
pub const ConnectorPunctuation: GeneralCategoryGroup = _
(Pc
) A connecting punctuation mark, like a tie
sourcepub const InitialPunctuation: GeneralCategoryGroup = _
pub const InitialPunctuation: GeneralCategoryGroup = _
(Pi
) An initial quotation mark
sourcepub const FinalPunctuation: GeneralCategoryGroup = _
pub const FinalPunctuation: GeneralCategoryGroup = _
(Pf
) A final quotation mark
sourcepub const OtherPunctuation: GeneralCategoryGroup = _
pub const OtherPunctuation: GeneralCategoryGroup = _
(Po
) A punctuation mark of other type
sourcepub const Punctuation: GeneralCategoryGroup = _
pub const Punctuation: GeneralCategoryGroup = _
(P
) The union of all punctuation categories
sourcepub const MathSymbol: GeneralCategoryGroup = _
pub const MathSymbol: GeneralCategoryGroup = _
(Sm
) A symbol of mathematical use
sourcepub const CurrencySymbol: GeneralCategoryGroup = _
pub const CurrencySymbol: GeneralCategoryGroup = _
(Sc
) A currency sign
sourcepub const ModifierSymbol: GeneralCategoryGroup = _
pub const ModifierSymbol: GeneralCategoryGroup = _
(Sk
) A non-letterlike modifier symbol
sourcepub const OtherSymbol: GeneralCategoryGroup = _
pub const OtherSymbol: GeneralCategoryGroup = _
(So
) A symbol of other type
sourcepub const Symbol: GeneralCategoryGroup = _
pub const Symbol: GeneralCategoryGroup = _
(S
) The union of all symbol categories
sourcepub const fn contains(&self, val: GeneralCategory) -> bool
pub const fn contains(&self, val: GeneralCategory) -> bool
Return whether the code point belongs in the provided multi-value category.
use icu::properties::CodePointMapData;
use icu::properties::props::{GeneralCategory, GeneralCategoryGroup};
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}')));
sourcepub const fn complement(self) -> GeneralCategoryGroup
pub const fn complement(self) -> GeneralCategoryGroup
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));
sourcepub const fn all() -> GeneralCategoryGroup
pub const fn all() -> GeneralCategoryGroup
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));
sourcepub const fn empty() -> GeneralCategoryGroup
pub const fn empty() -> GeneralCategoryGroup
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));
sourcepub const fn union(self, other: GeneralCategoryGroup) -> GeneralCategoryGroup
pub const fn union(self, other: GeneralCategoryGroup) -> GeneralCategoryGroup
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));
sourcepub const fn intersection(
self,
other: GeneralCategoryGroup,
) -> GeneralCategoryGroup
pub const fn intersection( self, other: GeneralCategoryGroup, ) -> GeneralCategoryGroup
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));
Trait Implementations§
source§impl AsULE for GeneralCategoryGroup
impl AsULE for GeneralCategoryGroup
source§type ULE = RawBytesULE<2>
type ULE = RawBytesULE<2>
Self
. Read moresource§fn to_unaligned(self) -> <GeneralCategoryGroup as AsULE>::ULE
fn to_unaligned(self) -> <GeneralCategoryGroup as AsULE>::ULE
source§fn from_unaligned(
ule: <GeneralCategoryGroup as AsULE>::ULE,
) -> GeneralCategoryGroup
fn from_unaligned( ule: <GeneralCategoryGroup as AsULE>::ULE, ) -> GeneralCategoryGroup
source§impl Clone for GeneralCategoryGroup
impl Clone for GeneralCategoryGroup
source§fn clone(&self) -> GeneralCategoryGroup
fn clone(&self) -> GeneralCategoryGroup
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for GeneralCategoryGroup
impl Debug for GeneralCategoryGroup
source§impl From<GeneralCategory> for GeneralCategoryGroup
impl From<GeneralCategory> for GeneralCategoryGroup
source§fn from(subcategory: GeneralCategory) -> GeneralCategoryGroup
fn from(subcategory: GeneralCategory) -> GeneralCategoryGroup
source§impl From<u32> for GeneralCategoryGroup
impl From<u32> for GeneralCategoryGroup
source§fn from(mask: u32) -> GeneralCategoryGroup
fn from(mask: u32) -> GeneralCategoryGroup
source§impl PartialEq for GeneralCategoryGroup
impl PartialEq for GeneralCategoryGroup
source§impl TrieValue for GeneralCategoryGroup
impl TrieValue for GeneralCategoryGroup
source§type TryFromU32Error = TryFromIntError
type TryFromU32Error = TryFromIntError
source§fn try_from_u32(
i: u32,
) -> Result<GeneralCategoryGroup, <GeneralCategoryGroup as TrieValue>::TryFromU32Error>
fn try_from_u32( i: u32, ) -> Result<GeneralCategoryGroup, <GeneralCategoryGroup as TrieValue>::TryFromU32Error>
u32
first.impl Copy for GeneralCategoryGroup
impl Eq for GeneralCategoryGroup
impl ParseableEnumeratedProperty for GeneralCategoryGroup
impl StructuralPartialEq for GeneralCategoryGroup
Auto Trait Implementations§
impl Freeze for GeneralCategoryGroup
impl RefUnwindSafe for GeneralCategoryGroup
impl Send for GeneralCategoryGroup
impl Sync for GeneralCategoryGroup
impl Unpin for GeneralCategoryGroup
impl UnwindSafe for GeneralCategoryGroup
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