Function rustrict::add_word

source ·
pub unsafe fn add_word(word: &str, typ: Type)
👎Deprecated: Use the equivalent Trie::customize_default().set(word, typ) or the safe API Censor::with_trie
Expand description

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.

Prefer the safe API Censor::with_trie, using a modified Trie::default().

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).

Safety

This must not be called when the crate is being used in any other way. It is best to call this from the main thread, near the beginning of the program.