1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/// Loads the list of words into a `Vec<String>`
/// 
/// Example:
/// ```
/// use sensitive_words::words;
/// 
/// let my_word = "cool!";
/// if words().contains(&my_word.to_string()) {
///   println!("Cool!");
/// }
/// ```
pub fn words() -> Vec<String> {
  let contents = include_str!("en.txt");

  let words: Vec<String> = contents
      .split('\n')
      .map(|w| w.to_string())
      .collect();

  words
}


#[test]
fn loads_words() {
  let w = words();

  assert_eq!(w.iter().find(|w| w.trim() == "zoophilia".to_string()), Some(&"zoophilia".to_string()));
}