hacker_text/
lib.rs

1//! A really dumb library that generates bogus lines of "hacker text".
2//!
3//! Example:
4//! ```
5//! use hacker_text::*;
6//! 
7//! let foo = make_line();
8//! // since the thing is randomized, it is impossible to know what foo will be.
9//! ```
10//!
11//! Some generated examples are:
12//! 
13//! * detonating python
14//! * sadly lying to golden trans rights
15//! * happily detonating all of gnu
16//! * destroying 20 million copies of the game tux kart racing
17//! * smoking tomato sauce
18//! * happily compiling windows
19//!
20//! (probably don't use the make_line() function, the adverbs and adjectives are really weird)
21
22#[cfg(test)]
23mod tests {
24    use super::*;
25
26    #[test]
27    fn verb_test() {
28        assert!(verb_list().contains(&get_verb()));
29    }
30
31    #[test]
32    fn noun_test() {
33        assert!(noun_list().contains(&get_verb()));
34    }
35}
36
37fn verb_list() -> Vec<&'static str> {
38    vec![
39        "launching",
40        "exploding",
41        "starting",
42        "stopping",
43        "activating",
44        "deactivating",
45        "destroying",
46        "defenstrating",
47        "shooting",
48        "compiling",
49        "connecting to",
50        "leaking",
51        "liquefying",
52        "revoking",
53        "exiting",
54        "spoofing",
55        "solving",
56        "lying to",
57        "walking to",
58        "decimating",
59        "obliterating",
60        "crushing",
61        "squishing",
62        "lightly tapping",
63        "performing percussive maintenance on",
64        "killing",
65        "uninstalling",
66        "reinstalling",
67        "updating",
68        "detonating",
69        "spending",
70        "smoking",
71        "snorting",
72        "synchronizing",
73        "sacrificing",
74        "smelting",
75        "attaching",
76        "crafting",
77        "inflating",
78        "rendering",
79        "recieving",
80    ]
81}
82
83/// Gets a verb from the list of verbs used in the `make_line()` functions.
84pub fn get_verb() -> &'static str {
85    let v = verb_list();
86    v[fastrand::usize(..v.len())]
87}
88
89fn noun_list() -> Vec<&'static str> {
90    vec![
91        "nukes",
92        "super epic hacking program",
93        "https injector", 
94        "installer",
95        "operating system",
96        "linux",
97        "all of gnu",
98        "explosions",
99        "artillery",
100        "UFOs",
101        "the abyss",
102        "anthropologists",
103        "castles",
104        "obliterators",
105        "bloodstained floorboards",
106        "700 cans of paint",
107        "around 0,000 04 gigatons of steel",
108        "france",
109        "neovim",
110        "vim",
111        "emacs",
112        "vi",
113        "nano",
114        "ipod nano",
115        "notepad",
116        "internet explorer",
117        "windows",
118        "mac",
119        "macOS",
120        "apple",
121        "garbage",
122        "windows phone",
123        "microsoft",
124        "holyc",
125        "c",
126        "rust",
127        "go",
128        "python",
129        "c++",
130        "html",
131        "css",
132        "20 million copies of the game tux kart racing",
133        "every single integer",
134        "hell",
135        "3 000 foobucks",
136        "somebody's mom's credit card",
137        "everything",
138        "sensor",
139        "noise",
140        "flux",
141        "phase",
142        "widget",
143        "protocol",
144        "all of the internet",
145        "magnet",
146        "tomato sauce",
147        "spaghetti",
148        "boiling water",
149        "pot",
150        "strainer",
151        "meatballs",
152        "yummy plate of spaghetti and meatballs",
153        "voltage",
154        "cocaine",
155        "meth",
156        "you",
157        "log by bolb",
158        "trans rights",
159        "lgbtq+ rights",
160        "myself",
161        "ether",
162        "electrons",
163        "positrons",
164        "rocket silo",
165    ]
166}
167
168/// Gets a noun from the list of nouns used in the `make_line()` functions.
169pub fn get_noun() -> &'static str {
170    let v = noun_list();
171    v[fastrand::usize(..v.len())]
172}
173
174fn adjective_list() -> Vec<&'static str> {
175    vec![
176        "large",
177        "red",
178        "blue",
179        "green",
180        "orange",
181        "yellow",
182        "golden",
183        "explosive",
184        "small",
185        "arrogant",
186        "bad",
187        "very green",
188        "incredibly green",
189        "indescribably green",
190        "inexplainibly green",
191        "supremely green",
192        "oxidized",
193        "rusted",
194    ]
195}
196
197/// Gets an adjective from the list of adjectives used in the `make_line()` functions.
198pub fn get_adjective() -> &'static str {
199    let v = adjective_list();
200    v[fastrand::usize(..v.len())]
201}
202
203fn adverb_list() -> Vec<&'static str> {
204    vec![
205        "happily",
206        "sadly",
207        "awfully",
208        "grealty",
209        "speedily",
210        "explosively",
211        "painfully",
212        "terribly",
213        "hopelessly",
214        "hopefully",
215        "wearily",
216        "achingly",
217        "smartly",
218        "stupidly",
219    ]
220}
221
222/// Gets an adverb from the list of adverbs used in the `make_line()` functions.
223pub fn get_adverb() -> &'static str {
224    let v = adverb_list();
225    v[fastrand::usize(..v.len())]
226}
227
228
229/// Returns a `String` with verbs and nouns.
230pub fn make_verb_line() -> String {
231    format!("{} {}", get_verb(), get_noun())
232}
233
234/// Returns a `String` with verbs, nouns, and adjectives.
235pub fn make_adjective_line() -> String {
236    format!("{} {} {}", get_verb(), get_adjective(), get_noun())
237}
238
239/// Returns a `String` with adverbs, verbs, and nouns.
240pub fn make_adverb_line() -> String {
241    format!("{} {} {}", get_adverb(), get_verb(), get_noun())
242}
243
244/// Returns a `String` with adverbs, verbs, nouns, and adjectives.
245pub fn make_everything_line() -> String {
246    format!("{} {} {} {}", get_adverb(), get_verb(), get_adjective(), get_noun())
247}
248
249/// Randomly picks one of the other `make_line` functions and returns a `String` from them.
250pub fn make_line() -> String {
251    match fastrand::i32(0..3) {
252        0 => make_verb_line(),
253        1 => make_adjective_line(),
254        2 => make_adverb_line(),
255        3 => make_line(),
256        _ => panic!("somehow got something other then 0, 1, 2 or 3 from randomizing a range of 0..3. this should be impossible!")
257    }
258}