sensitive_words/lib.rs
1/// Loads the list of words into a `Vec<String>`
2///
3/// Example:
4/// ```
5/// use sensitive_words::words;
6///
7/// let my_word = "cool!";
8/// if words().contains(&my_word.to_string()) {
9/// println!("Cool!");
10/// }
11/// ```
12pub fn words() -> Vec<String> {
13 let contents = include_str!("en.txt");
14
15 let words: Vec<String> = contents
16 .split('\n')
17 .map(|w| w.to_string())
18 .collect();
19
20 words
21}
22
23
24#[test]
25fn loads_words() {
26 let w = words();
27
28 assert_eq!(w.iter().find(|w| w.trim() == "zoophilia".to_string()), Some(&"zoophilia".to_string()));
29}