Struct icu_experimental::transliterate::RuleCollection
source · pub struct RuleCollection { /* private fields */ }
Expand description
A collection of transliteration rules.
✨ Enabled with the compile
Cargo feature.
§Example
use icu::experimental::transliterate::{RuleCollection, Transliterator};
let mut collection = RuleCollection::default();
collection.register_source(
&"de-t-de-d0-ascii".parse().unwrap(),
r#"
$AE = [Ä {A \u0308}];
$OE = [Ö {O \u0308}];
$UE = [Ü {U \u0308}];
[ä {a \u0308}] → ae;
[ö {o \u0308}] → oe;
[ü {u \u0308}] → ue;
{$AE} [:Lowercase:] → Ae;
{$OE} [:Lowercase:] → Oe;
{$UE} [:Lowercase:] → Ue;
$AE → AE;
$OE → OE;
$UE → UE;
::Any-ASCII;
"#.to_string(),
// legacy alias, doesn't actually do anything in this case
["de-ASCII"],
false,
true,
);
collection.register_source(
&"und-t-und-latn-d0-ascii".parse().unwrap(),
"# ... ".to_string(),
// the previous transliterator refers to this one by the `Any-ASCII` ID,
// so it's important that the alias is listed here.
["Latin-Ascii", "Any-ASCII"],
false,
true,
);
let t = Transliterator::try_new_unstable(&collection.as_provider(), &collection.as_provider(), &"de-t-de-d0-ascii".parse().unwrap()).unwrap();
assert_eq!(t.transliterate("Käse".into()), "Kaese");
Implementations§
source§impl RuleCollection
impl RuleCollection
sourcepub fn register_source<'a>(
&mut self,
id: &Locale,
source: String,
aliases: impl IntoIterator<Item = &'a str>,
reverse: bool,
visible: bool,
)
pub fn register_source<'a>( &mut self, id: &Locale, source: String, aliases: impl IntoIterator<Item = &'a str>, reverse: bool, visible: bool, )
Add a new transliteration source to the collection.
sourcepub fn register_aliases<'a>(
&mut self,
id: &Locale,
aliases: impl IntoIterator<Item = &'a str>,
)
pub fn register_aliases<'a>( &mut self, id: &Locale, aliases: impl IntoIterator<Item = &'a str>, )
Add transliteration ID aliases without registering a source.
sourcepub fn as_provider(&self) -> RuleCollectionProvider<'_, Baked, Baked>
pub fn as_provider(&self) -> RuleCollectionProvider<'_, Baked, Baked>
Returns a provider that is usable by Transliterator::try_new_unstable
.
✨ Enabled with the compiled_data
Cargo feature.
sourcepub fn as_provider_unstable<'a, PP, NP>(
&'a self,
properties_provider: &'a PP,
normalizer_provider: &'a NP,
) -> Result<RuleCollectionProvider<'a, PP, NP>, DataError>where
PP: ?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<GraphemeClusterBreakV1Marker> + DataProvider<GraphemeClusterBreakNameToValueV2Marker> + 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<SentenceBreakV1Marker> + DataProvider<SentenceBreakNameToValueV2Marker> + DataProvider<SentenceTerminalV1Marker> + DataProvider<SoftDottedV1Marker> + DataProvider<TerminalPunctuationV1Marker> + DataProvider<UnifiedIdeographV1Marker> + DataProvider<UppercaseV1Marker> + DataProvider<VariationSelectorV1Marker> + DataProvider<WhiteSpaceV1Marker> + DataProvider<WordBreakV1Marker> + DataProvider<WordBreakNameToValueV2Marker> + DataProvider<XidContinueV1Marker> + DataProvider<GeneralCategoryMaskNameToValueV2Marker> + DataProvider<GeneralCategoryV1Marker> + DataProvider<ScriptNameToValueV2Marker> + DataProvider<ScriptV1Marker> + DataProvider<ScriptWithExtensionsPropertyV1Marker> + DataProvider<XidStartV1Marker>,
NP: ?Sized + DataProvider<CanonicalDecompositionDataV2Marker> + DataProvider<CompatibilityDecompositionDataV2Marker> + DataProvider<CanonicalDecompositionTablesV1Marker> + DataProvider<CompatibilityDecompositionTablesV1Marker> + DataProvider<CanonicalCompositionsV1Marker>,
pub fn as_provider_unstable<'a, PP, NP>(
&'a self,
properties_provider: &'a PP,
normalizer_provider: &'a NP,
) -> Result<RuleCollectionProvider<'a, PP, NP>, DataError>where
PP: ?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<GraphemeClusterBreakV1Marker> + DataProvider<GraphemeClusterBreakNameToValueV2Marker> + 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<SentenceBreakV1Marker> + DataProvider<SentenceBreakNameToValueV2Marker> + DataProvider<SentenceTerminalV1Marker> + DataProvider<SoftDottedV1Marker> + DataProvider<TerminalPunctuationV1Marker> + DataProvider<UnifiedIdeographV1Marker> + DataProvider<UppercaseV1Marker> + DataProvider<VariationSelectorV1Marker> + DataProvider<WhiteSpaceV1Marker> + DataProvider<WordBreakV1Marker> + DataProvider<WordBreakNameToValueV2Marker> + DataProvider<XidContinueV1Marker> + DataProvider<GeneralCategoryMaskNameToValueV2Marker> + DataProvider<GeneralCategoryV1Marker> + DataProvider<ScriptNameToValueV2Marker> + DataProvider<ScriptV1Marker> + DataProvider<ScriptWithExtensionsPropertyV1Marker> + DataProvider<XidStartV1Marker>,
NP: ?Sized + DataProvider<CanonicalDecompositionDataV2Marker> + DataProvider<CompatibilityDecompositionDataV2Marker> + DataProvider<CanonicalDecompositionTablesV1Marker> + DataProvider<CompatibilityDecompositionTablesV1Marker> + DataProvider<CanonicalCompositionsV1Marker>,
A version of Self::as_provider
that uses custom data provided by a DataProvider
.
⚠️ The bounds on provider may change over time, including in SemVer minor releases.
Trait Implementations§
source§impl Debug for RuleCollection
impl Debug for RuleCollection
source§impl Default for RuleCollection
impl Default for RuleCollection
source§fn default() -> RuleCollection
fn default() -> RuleCollection
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for RuleCollection
impl !RefUnwindSafe for RuleCollection
impl Send for RuleCollection
impl !Sync for RuleCollection
impl Unpin for RuleCollection
impl UnwindSafe for RuleCollection
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
Mutably borrows from an owned value. Read more
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> ⓘ
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 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> ⓘ
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