Enum censor::Censor

source ·
pub enum Censor {
    Standard,
    Sex,
    Zealous,
    Custom(HashSet<String>),
}
Expand description

A collection of words to censor

Variants

Standard

Standard swear words

For more information, see STANDARD_WORDS

Sex

Words related to sex

Not usually used by itself

For more information, see SEX_WORDS

Zealous

Words that are profanities only to the zealous

Not usually used by itself

For more information, see ZEALOUS_WORDS

Custom(HashSet<String>)

A custom set of words

Implementations

Create an empty Censor

Create a Censor::Custom

Check if a string contains censored words

Count the number of censored words in a string

Example
use censor::*;

let censor = Censor::Standard;

assert_eq!(0, censor.count("dog"));
assert_eq!(1, censor.count("motherfucker"));
assert_eq!(2, censor.count("bitch ass guy"));

Replace censored words in the string with asterisks (*s)

Replace censored words in the string with characters from a ‘grawlix’ string (#?!@$)

Panics

Panics if the grawlix string is empty

Replace censored words in the string with characters from a ‘grawlix’ string (#?!@$)

Characters at indices within the given offsets from the start and end of words will not be censored

Panics

Panics if the grawlix string is empty

Get a set of the indices of characters in the given string that are part of censored words

Get a reference to the set used by the Censor

Get an iterator over all censored words

Find a censored word in the Censor. Applies character aliases

Check if the Censor contains a word. Applies character aliases

Trait Implementations

The resulting type after applying the + operator.
Performs the + operation. Read more
The resulting type after applying the + operator.
Performs the + operation. Read more
Performs the += operation. Read more
Performs the += operation. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
Performs the -= operation. Read more
Performs the -= operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.