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

source

pub const fn new<P: BinaryProperty>() -> CodePointSetDataBorrowed<'static>

Creates a new CodePointSetData for a BinaryProperty.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

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.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

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.

source

pub fn from_code_point_inversion_list( set: CodePointInversionList<'static>, ) -> Self

Construct a new owned [CodePointInversionList]

source

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.

source

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

source

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 and General_Category: handle these directly using property values parsed via PropertyParser<GeneralCategory> and PropertyParser<Script> if necessary.
  • Script_Extensions: handle this directly using APIs from crate::script::ScriptWithExtensions
  • General_Category mask values: Handle this alongside General_Category using GeneralCategoryGroup, using property values parsed via PropertyParser<GeneralCategory> if necessary
  • Assigned, All, and ASCII 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 set gc=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 corresponding GeneralCategory set.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

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'));
source

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.

📚 Help choosing a constructor

source

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.

📚 Help choosing a constructor

source

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.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.

Trait Implementations§

source§

impl Debug for CodePointSetData

source§

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

Formats the value using the given formatter. Read more

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> 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,