pub struct Trie { /* private fields */ }censor only.Expand description
Efficiently stores profanity, false positives, and safe words.
Implementations§
Source§impl Trie
impl Trie
Sourcepub unsafe fn customize_default() -> &'static mut Self
Available on crate feature customize only.
pub unsafe fn customize_default() -> &'static mut Self
customize only.Allows direct mutable access to the global default trie of words.
Prefer the safe API Censor::with_trie.
§Safety
You must manually avoid concurrent access/censoring.
Sourcepub fn set(&mut self, word: &str, typ: Type)
pub fn set(&mut self, word: &str, typ: Type)
Adds a word, with the given type. The type can be Type::SAFE, or a combination of Type::PROFANE,
Type::Sexual, Type::Offensive, Type::Mean, Type::Mild, Type::Moderate, and Type::Severe,
but NOT both (can’t be safe and unsafe).
It is recommended to use all lower-case, which will match both cases. Upper-case characters will only match upper-case.
§Warning
Any profanity words added this way will not support false positives. For example, if you add the word
“field,” you can expect “cornfield” to be detected as well, unless you call add_word("cornfield", Type::None).