Struct icu_properties::CodePointSetData
source · pub struct CodePointSetData { /* private fields */ }
Expand description
A set of Unicode code points. Access its data via the borrowed version,
CodePointSetDataBorrowed
.
§Example
use icu::properties::CodePointSetData;
use icu::properties::props::Alphabetic;
let alphabetic = CodePointSetData::new::<Alphabetic>();
assert!(!alphabetic.contains('3'));
assert!(!alphabetic.contains('੩')); // U+0A69 GURMUKHI DIGIT THREE
assert!(alphabetic.contains('A'));
assert!(alphabetic.contains('Ä')); // U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS
Implementations§
source§impl CodePointSetData
impl CodePointSetData
sourcepub const fn new<P: BinaryProperty>() -> CodePointSetDataBorrowed<'static>
pub const fn new<P: BinaryProperty>() -> CodePointSetDataBorrowed<'static>
Creates a new CodePointSetData
for a BinaryProperty
.
✨ Enabled with the compiled_data
Cargo feature.
sourcepub fn try_new_unstable<P: BinaryProperty>(
provider: &(impl DataProvider<P::DataMarker> + ?Sized),
) -> Result<CodePointSetData, DataError>
pub fn try_new_unstable<P: BinaryProperty>( provider: &(impl DataProvider<P::DataMarker> + ?Sized), ) -> Result<CodePointSetData, DataError>
A version of Self::new
that uses custom data provided by a DataProvider
.
sourcepub fn as_borrowed(&self) -> CodePointSetDataBorrowed<'_>
pub fn as_borrowed(&self) -> CodePointSetDataBorrowed<'_>
Construct a borrowed version of this type that can be queried.
This owned version if returned by functions that use a runtime data provider.
sourcepub fn from_code_point_inversion_list(
set: CodePointInversionList<'static>,
) -> Self
pub fn from_code_point_inversion_list( set: CodePointInversionList<'static>, ) -> Self
Construct a new owned [CodePointInversionList
]
sourcepub fn as_code_point_inversion_list(
&self,
) -> Option<&CodePointInversionList<'_>>
pub fn as_code_point_inversion_list( &self, ) -> Option<&CodePointInversionList<'_>>
Convert this type to a [CodePointInversionList
] as a borrowed value.
The data backing this is extensible and supports multiple implementations.
Currently it is always [CodePointInversionList
]; however in the future more backends may be
added, and users may select which at data generation time.
This method returns an Option
in order to return None
when the backing data provider
cannot return a [CodePointInversionList
], or cannot do so within the expected constant time
constraint.
sourcepub fn to_code_point_inversion_list(&self) -> CodePointInversionList<'_>
pub fn to_code_point_inversion_list(&self) -> CodePointInversionList<'_>
Convert this type to a [CodePointInversionList
], borrowing if possible,
otherwise allocating a new [CodePointInversionList
].
The data backing this is extensible and supports multiple implementations.
Currently it is always [CodePointInversionList
]; however in the future more backends may be
added, and users may select which at data generation time.
The performance of the conversion to this specific return type will vary
depending on the data structure that is backing self
.
source§impl CodePointSetData
impl CodePointSetData
sourcepub fn new_for_ecma262(prop: &[u8]) -> Option<CodePointSetDataBorrowed<'static>>
pub fn new_for_ecma262(prop: &[u8]) -> Option<CodePointSetDataBorrowed<'static>>
Returns a type capable of looking up values for a property specified as a string, as long as it is a binary property listed in ECMA-262, using strict matching on the names in the spec.
This handles every property required by ECMA-262 /u
regular expressions, except for:
Script
andGeneral_Category
: handle these directly using property values parsed viaPropertyParser<GeneralCategory>
andPropertyParser<Script>
if necessary.Script_Extensions
: handle this directly using APIs fromcrate::script::ScriptWithExtensions
General_Category
mask values: Handle this alongsideGeneral_Category
usingGeneralCategoryGroup
, using property values parsed viaPropertyParser<GeneralCategory>
if necessaryAssigned
,All
, andASCII
pseudoproperties: Handle these using their equivalent sets:Any
can be expressed as the range[\u{0}-\u{10FFFF}]
Assigned
can be expressed as the inverse of the setgc=Cn
(i.e.,\P{gc=Cn}
).ASCII
can be expressed as the range[\u{0}-\u{7F}]
General_Category
property values can themselves be treated like properties using a shorthand in ECMA262, simply create the correspondingGeneralCategory
set.
✨ Enabled with the compiled_data
Cargo feature.
use icu::properties::CodePointSetData;
let emoji = CodePointSetData::new_for_ecma262(b"Emoji")
.expect("is an ECMA-262 property");
assert!(emoji.contains('🔥')); // U+1F525 FIRE
assert!(!emoji.contains('V'));
sourcepub fn try_new_for_ecma262_with_buffer_provider(
provider: &(impl AnyProvider + ?Sized),
prop: &[u8],
) -> Option<Result<Self, DataError>>
pub fn try_new_for_ecma262_with_buffer_provider( provider: &(impl AnyProvider + ?Sized), prop: &[u8], ) -> Option<Result<Self, DataError>>
A version of [Self :: new_for_ecma262
] that uses custom data provided by an AnyProvider
.
sourcepub fn try_new_for_ecma262_with_any_provider(
provider: &(impl BufferProvider + ?Sized),
prop: &[u8],
) -> Option<Result<Self, DataError>>
pub fn try_new_for_ecma262_with_any_provider( provider: &(impl BufferProvider + ?Sized), prop: &[u8], ) -> Option<Result<Self, DataError>>
A version of [Self :: new_for_ecma262
] that uses custom data provided by a BufferProvider
.
✨ Enabled with the serde
feature.
sourcepub fn try_new_for_ecma262_unstable<P>(
provider: &P,
prop: &[u8],
) -> Option<Result<Self, DataError>>where
P: ?Sized + DataProvider<AsciiHexDigitV1Marker> + DataProvider<AlphabeticV1Marker> + DataProvider<BidiControlV1Marker> + DataProvider<BidiMirroredV1Marker> + DataProvider<CaseIgnorableV1Marker> + DataProvider<CasedV1Marker> + DataProvider<ChangesWhenCasefoldedV1Marker> + DataProvider<ChangesWhenCasemappedV1Marker> + DataProvider<ChangesWhenLowercasedV1Marker> + DataProvider<ChangesWhenNfkcCasefoldedV1Marker> + DataProvider<ChangesWhenTitlecasedV1Marker> + DataProvider<ChangesWhenUppercasedV1Marker> + DataProvider<DashV1Marker> + DataProvider<DefaultIgnorableCodePointV1Marker> + DataProvider<DeprecatedV1Marker> + DataProvider<DiacriticV1Marker> + DataProvider<EmojiV1Marker> + DataProvider<EmojiComponentV1Marker> + DataProvider<EmojiModifierV1Marker> + DataProvider<EmojiModifierBaseV1Marker> + DataProvider<EmojiPresentationV1Marker> + DataProvider<ExtendedPictographicV1Marker> + DataProvider<ExtenderV1Marker> + DataProvider<GraphemeBaseV1Marker> + DataProvider<GraphemeExtendV1Marker> + DataProvider<HexDigitV1Marker> + DataProvider<IdsBinaryOperatorV1Marker> + DataProvider<IdsTrinaryOperatorV1Marker> + DataProvider<IdContinueV1Marker> + DataProvider<IdStartV1Marker> + DataProvider<IdeographicV1Marker> + DataProvider<JoinControlV1Marker> + DataProvider<LogicalOrderExceptionV1Marker> + DataProvider<LowercaseV1Marker> + DataProvider<MathV1Marker> + DataProvider<NoncharacterCodePointV1Marker> + DataProvider<PatternSyntaxV1Marker> + DataProvider<PatternWhiteSpaceV1Marker> + DataProvider<QuotationMarkV1Marker> + DataProvider<RadicalV1Marker> + DataProvider<RegionalIndicatorV1Marker> + DataProvider<SentenceTerminalV1Marker> + DataProvider<SoftDottedV1Marker> + DataProvider<TerminalPunctuationV1Marker> + DataProvider<UnifiedIdeographV1Marker> + DataProvider<UppercaseV1Marker> + DataProvider<VariationSelectorV1Marker> + DataProvider<WhiteSpaceV1Marker> + DataProvider<XidContinueV1Marker> + DataProvider<XidStartV1Marker>,
pub fn try_new_for_ecma262_unstable<P>(
provider: &P,
prop: &[u8],
) -> Option<Result<Self, DataError>>where
P: ?Sized + DataProvider<AsciiHexDigitV1Marker> + DataProvider<AlphabeticV1Marker> + DataProvider<BidiControlV1Marker> + DataProvider<BidiMirroredV1Marker> + DataProvider<CaseIgnorableV1Marker> + DataProvider<CasedV1Marker> + DataProvider<ChangesWhenCasefoldedV1Marker> + DataProvider<ChangesWhenCasemappedV1Marker> + DataProvider<ChangesWhenLowercasedV1Marker> + DataProvider<ChangesWhenNfkcCasefoldedV1Marker> + DataProvider<ChangesWhenTitlecasedV1Marker> + DataProvider<ChangesWhenUppercasedV1Marker> + DataProvider<DashV1Marker> + DataProvider<DefaultIgnorableCodePointV1Marker> + DataProvider<DeprecatedV1Marker> + DataProvider<DiacriticV1Marker> + DataProvider<EmojiV1Marker> + DataProvider<EmojiComponentV1Marker> + DataProvider<EmojiModifierV1Marker> + DataProvider<EmojiModifierBaseV1Marker> + DataProvider<EmojiPresentationV1Marker> + DataProvider<ExtendedPictographicV1Marker> + DataProvider<ExtenderV1Marker> + DataProvider<GraphemeBaseV1Marker> + DataProvider<GraphemeExtendV1Marker> + DataProvider<HexDigitV1Marker> + DataProvider<IdsBinaryOperatorV1Marker> + DataProvider<IdsTrinaryOperatorV1Marker> + DataProvider<IdContinueV1Marker> + DataProvider<IdStartV1Marker> + DataProvider<IdeographicV1Marker> + DataProvider<JoinControlV1Marker> + DataProvider<LogicalOrderExceptionV1Marker> + DataProvider<LowercaseV1Marker> + DataProvider<MathV1Marker> + DataProvider<NoncharacterCodePointV1Marker> + DataProvider<PatternSyntaxV1Marker> + DataProvider<PatternWhiteSpaceV1Marker> + DataProvider<QuotationMarkV1Marker> + DataProvider<RadicalV1Marker> + DataProvider<RegionalIndicatorV1Marker> + DataProvider<SentenceTerminalV1Marker> + DataProvider<SoftDottedV1Marker> + DataProvider<TerminalPunctuationV1Marker> + DataProvider<UnifiedIdeographV1Marker> + DataProvider<UppercaseV1Marker> + DataProvider<VariationSelectorV1Marker> + DataProvider<WhiteSpaceV1Marker> + DataProvider<XidContinueV1Marker> + DataProvider<XidStartV1Marker>,
A version of Self::new_for_ecma262
that uses custom data provided by a DataProvider
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CodePointSetData
impl RefUnwindSafe for CodePointSetData
impl Send for CodePointSetData
impl Sync for CodePointSetData
impl Unpin for CodePointSetData
impl UnwindSafe for CodePointSetData
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> 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