pub struct Options(/* private fields */);
Expand description
A configuration struct where you can customize decancer’s behavior.
By default, decancer cures as much characters as possible and turns all the output characters to lowercase.
If you don’t plan on using this struct and only using decancer’s defaults, it’s recommended to disable the default options
feature flag to optimize away unnecessary option checks.
use decancer::Options;
// by default, all options are disabled
let _options = Options::default();
Implementations§
Source§impl Options
impl Options
Sourcepub const fn pure_homoglyph() -> Self
pub const fn pure_homoglyph() -> Self
Creates a new configuration that prevents decancer from curing characters from major foreign writing systems, including diacritics.
Sourcepub const fn retain_capitalization(self) -> Self
pub const fn retain_capitalization(self) -> Self
Prevents decancer from changing all characters to lowercase. Therefore, if the input character is in uppercase, the output character will be in uppercase as well.
NOTE: Many confusables are neither an uppercase or a lowercase character. Therefore, the decancer defaults to displaying the translation in lowercase:
use decancer::{Translation, Options};
use std::borrow::Cow;
let options = Options::default()
.retain_capitalization();
assert_eq!('🆐'.to_lowercase().collect::<String>(), '🆐'.to_uppercase().collect::<String>());
assert_eq!(decancer::cure_char('🆐', options), Translation::String(Cow::Borrowed("dj")));
Sourcepub const fn disable_bidi(self) -> Self
pub const fn disable_bidi(self) -> Self
Prevents decancer from applying the Unicode Bidirectional Algorithm. Use this only when you don’t expect any right-to-left characters. Enabling this option has no effect if it’s called on cure_char
.
NOTE: This speeds up the function call, but can break right-to-left characters. It’s highly recommended to also use retain_arabic
and retain_hebrew
.
Sourcepub const fn retain_diacritics(self) -> Self
pub const fn retain_diacritics(self) -> Self
Prevents decancer from curing characters with diacritics or accents.
NOTE: Decancer can still cure standalone diacritic characters, which is used in Zalgo texts.
Sourcepub const fn retain_japanese(self) -> Self
pub const fn retain_japanese(self) -> Self
Prevents decancer from curing all katakana and hiragana characters.
NOTE: To also provent decancer from curing kanji characters, use retain_chinese
.
Sourcepub const fn retain_emojis(self) -> Self
pub const fn retain_emojis(self) -> Self
Prevents decancer from curing all emojis.
Sourcepub const fn retain_turkish(self) -> Self
pub const fn retain_turkish(self) -> Self
Prevents decancer from curing all turkish characters.
NOTE: To also prevent decancer from curing the uppercase dotted i character (İ
), use retain_capitalization
.
Sourcepub const fn ascii_only(self) -> Self
pub const fn ascii_only(self) -> Self
Removes all non-ASCII characters from the result.
Sourcepub const fn alphanumeric_only(self) -> Self
pub const fn alphanumeric_only(self) -> Self
Removes all non-alphanumeric characters from the result.
Sourcepub const fn retain_greek(self) -> Self
pub const fn retain_greek(self) -> Self
Prevents decancer from curing all greek characters.
Sourcepub const fn retain_cyrillic(self) -> Self
pub const fn retain_cyrillic(self) -> Self
Prevents decancer from curing all cyrillic characters.
Sourcepub const fn retain_hebrew(self) -> Self
pub const fn retain_hebrew(self) -> Self
Prevents decancer from curing all hebrew characters.
Sourcepub const fn retain_arabic(self) -> Self
pub const fn retain_arabic(self) -> Self
Prevents decancer from curing all arabic characters.
Sourcepub const fn retain_devanagari(self) -> Self
pub const fn retain_devanagari(self) -> Self
Prevents decancer from curing all devanagari characters.
Sourcepub const fn retain_bengali(self) -> Self
pub const fn retain_bengali(self) -> Self
Prevents decancer from curing all bengali characters.
Sourcepub const fn retain_armenian(self) -> Self
pub const fn retain_armenian(self) -> Self
Prevents decancer from curing all armenian characters.
Sourcepub const fn retain_gujarati(self) -> Self
pub const fn retain_gujarati(self) -> Self
Prevents decancer from curing all gujarati characters.
Sourcepub const fn retain_tamil(self) -> Self
pub const fn retain_tamil(self) -> Self
Prevents decancer from curing all tamil characters.
Sourcepub const fn retain_thai(self) -> Self
pub const fn retain_thai(self) -> Self
Prevents decancer from curing all thai characters.
Sourcepub const fn retain_lao(self) -> Self
pub const fn retain_lao(self) -> Self
Prevents decancer from curing all lao characters.
Sourcepub const fn retain_burmese(self) -> Self
pub const fn retain_burmese(self) -> Self
Prevents decancer from curing all burmese characters.
Sourcepub const fn retain_khmer(self) -> Self
pub const fn retain_khmer(self) -> Self
Prevents decancer from curing all khmer characters.
Sourcepub const fn retain_mongolian(self) -> Self
pub const fn retain_mongolian(self) -> Self
Prevents decancer from curing all mongolian characters.
Sourcepub const fn retain_chinese(self) -> Self
pub const fn retain_chinese(self) -> Self
Prevents decancer from curing all chinese characters.
Sourcepub const fn retain_korean(self) -> Self
pub const fn retain_korean(self) -> Self
Prevents decancer from curing all korean characters.
Sourcepub const fn retain_braille(self) -> Self
pub const fn retain_braille(self) -> Self
Prevents decancer from curing all braille characters.