names/three/
mod.rs

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
//  MOD.rs
//    by Lut99
//
//  Created:
//    05 Jan 2024, 16:12:55
//  Last edited:
//    08 Jan 2024, 10:04:36
//  Auto updated?
//    Yes
//
//  Description:
//!   Defines three-letter names.
//


/***** CASE MODULES *****/
/// Defines the three-letter names in UPPERCASE.
///
/// # Example
/// ```rust
/// use names::three::uppercase;
///
/// assert_eq!(uppercase::AMY, "AMY");
/// assert_eq!(uppercase::DAN, "DAN");
/// ```
#[cfg(feature = "three-uppercase")]
pub mod uppercase {
    /// Uppercase version of `Amy`.
    pub const AMY: &'static str = "AMY";
    /// Uppercase version of `Bob`.
    pub const BOB: &'static str = "BOB";
    /// Uppercase version of `Cho`.
    pub const CHO: &'static str = "CHO";
    /// Uppercase version of `Dan`.
    pub const DAN: &'static str = "DAN";
    /// Uppercase version of `Eve`.
    pub const EVE: &'static str = "EVE";
    /// Uppercase version of `Fey`.
    pub const FEY: &'static str = "FEY";
    /// Uppercase version of `Guy`.
    pub const GUY: &'static str = "GUY";
    /// Uppercase version of `Han`.
    pub const HAN: &'static str = "HAN";
    /// Uppercase version of `Ian`.
    pub const IAN: &'static str = "IAN";
    /// Uppercase version of `Joe`.
    pub const JOE: &'static str = "JOE";
    /// Uppercase version of `Ken`.
    pub const KEN: &'static str = "KEN";
    /// Uppercase version of `Lea`.
    pub const LEA: &'static str = "LEA";
    /// Uppercase version of `Mel`.
    pub const MEL: &'static str = "MEL";
    /// Uppercase version of `Noa`.
    pub const NOA: &'static str = "NOA";
    /// Uppercase version of `Oni`.
    pub const ONI: &'static str = "ONI";
    /// Uppercase version of `Pam`.
    pub const PAM: &'static str = "PAM";
    /// Uppercase version of `Qin`.
    pub const QIN: &'static str = "QIN";
    /// Uppercase version of `Ron`.
    pub const RON: &'static str = "RON";
    /// Uppercase version of `Sam`.
    pub const SAM: &'static str = "SAM";
    /// Uppercase version of `Tim`.
    pub const TIM: &'static str = "TIM";
    /// Uppercase version of `Uwe`.
    pub const UWE: &'static str = "UWE";
    /// Uppercase version of `Vic`.
    pub const VIC: &'static str = "VIC";
    /// Uppercase version of `Wes`.
    pub const WES: &'static str = "WES";
    /// Uppercase version of `Xin`.
    pub const XIN: &'static str = "XIN";
    /// Uppercase version of `Yas`.
    pub const YAS: &'static str = "YAS";
    /// Uppercase version of `Zoe`.
    pub const ZOE: &'static str = "ZOE";


    /// Lists all uppercase names in this module.
    ///
    /// # Returns
    /// A `'static` slice of [`&static str`](str)s that list all the names.
    #[inline]
    pub const fn all() -> &'static [&'static str] {
        &[AMY, BOB, CHO, DAN, EVE, FEY, GUY, HAN, IAN, JOE, KEN, LEA, MEL, NOA, ONI, PAM, QIN, RON, SAM, TIM, UWE, VIC, WES, XIN, YAS, ZOE]
    }



    /// Selects a random name out of all three-letter UPPERCASE names.
    ///
    /// # Returns
    /// A [`&'static str`](str) that refers to a random constant in this crate.
    ///
    /// # Example
    /// ```rust
    /// use names::three::uppercase::rand;
    ///
    /// // Could print any of the `AMY`, `BOB`, `CHO`, ... names!
    /// println!("{}", rand());
    /// ```
    #[cfg(feature = "rand")]
    #[inline]
    pub fn rand() -> &'static str { rand_with(&mut rand::thread_rng()) }

    /// Selects a random name out of all three-letter UPPERCASE names using a provided Random Number Generator (RNG).
    ///
    /// # Arguments
    /// - `rng`: The random number generator (as an [`Rng`]) to use.
    ///
    /// # Returns
    /// A [`&'static str`](str) that refers to a random constant in this crate.
    ///
    /// # Example
    /// ```rust
    /// use names::three::uppercase::rand_with;
    ///
    /// // Could print any of the `AMY`, `BOB`, `CHO`, ... names!
    /// println!("{}", rand_with(&mut rand::thread_rng()));
    /// ```
    #[cfg(feature = "rand")]
    #[inline]
    pub fn rand_with(rng: &mut impl rand::Rng) -> &'static str {
        use rand::seq::SliceRandom as _;

        // For now, only one option, so ez
        all().choose(rng).unwrap()
    }
}
#[cfg(all(feature = "rand", feature = "three-uppercase"))]
pub use usualcase::{rand as rand_uppercase, rand_with as rand_uppercase_with};

/// Defines the three-letter names in proper case (i.e., only first character is capitalized).
///
/// # Example
/// ```rust
/// use names::three::usualcase;
///
/// assert_eq!(usualcase::AMY, "Amy");
/// assert_eq!(usualcase::DAN, "Dan");
/// ```
#[cfg(feature = "three-usualcase")]
pub mod usualcase {
    /// The name `Amy`.
    pub const AMY: &'static str = "Amy";
    /// The name `Bob`.
    pub const BOB: &'static str = "Bob";
    /// The name `Cho`.
    pub const CHO: &'static str = "Cho";
    /// The name `Dan`.
    pub const DAN: &'static str = "Dan";
    /// The name `Eve`.
    pub const EVE: &'static str = "Eve";
    /// The name `Fey`.
    pub const FEY: &'static str = "Fey";
    /// The name `Guy`.
    pub const GUY: &'static str = "Guy";
    /// The name `Han`.
    pub const HAN: &'static str = "Han";
    /// The name `Ian`.
    pub const IAN: &'static str = "Ian";
    /// The name `Joe`.
    pub const JOE: &'static str = "Joe";
    /// The name `Ken`.
    pub const KEN: &'static str = "Ken";
    /// The name `Lea`.
    pub const LEA: &'static str = "Lea";
    /// The name `Mel`.
    pub const MEL: &'static str = "Mel";
    /// The name `Noa`.
    pub const NOA: &'static str = "Noa";
    /// The name `Oni`.
    pub const ONI: &'static str = "Oni";
    /// The name `Pam`.
    pub const PAM: &'static str = "Pam";
    /// The name `Qin`.
    pub const QIN: &'static str = "Qin";
    /// The name `Ron`.
    pub const RON: &'static str = "Ron";
    /// The name `Sam`.
    pub const SAM: &'static str = "Sam";
    /// The name `Tim`.
    pub const TIM: &'static str = "Tim";
    /// The name `Uwe`.
    pub const UWE: &'static str = "Uwe";
    /// The name `Vic`.
    pub const VIC: &'static str = "Vic";
    /// The name `Wes`.
    pub const WES: &'static str = "Wes";
    /// The name `Xin`.
    pub const XIN: &'static str = "Xin";
    /// The name `Yas`.
    pub const YAS: &'static str = "Yas";
    /// The name `Zoe`.
    pub const ZOE: &'static str = "Zoe";


    /// Lists all usualcase names in this module.
    ///
    /// # Returns
    /// A `'static` slice of [`&static str`](str)s that list all the names.
    #[inline]
    pub const fn all() -> &'static [&'static str] {
        &[AMY, BOB, CHO, DAN, EVE, FEY, GUY, HAN, IAN, JOE, KEN, LEA, MEL, NOA, ONI, PAM, QIN, RON, SAM, TIM, UWE, VIC, WES, XIN, YAS, ZOE]
    }



    /// Selects a random name out of all three-letter Usualcase names.
    ///
    /// # Returns
    /// A [`&'static str`](str) that refers to a random constant in this crate.
    ///
    /// # Example
    /// ```rust
    /// use names::three::usualcase::rand;
    ///
    /// // Could print any of the `Amy`, `Bob`, `Cho`, ... names!
    /// println!("{}", rand());
    /// ```
    #[cfg(feature = "rand")]
    #[inline]
    pub fn rand() -> &'static str { rand_with(&mut rand::thread_rng()) }

    /// Selects a random name out of all three-letter Usualcase names using a provided Random Number Generator (RNG).
    ///
    /// # Arguments
    /// - `rng`: The random number generator (as an [`Rng`]) to use.
    ///
    /// # Returns
    /// A [`&'static str`](str) that refers to a random constant in this crate.
    ///
    /// # Example
    /// ```rust
    /// use names::three::usualcase::rand_with;
    ///
    /// // Could print any of the `Amy`, `Bob`, `Cho`, ... names!
    /// println!("{}", rand_with(&mut rand::thread_rng()));
    /// ```
    #[cfg(feature = "rand")]
    #[inline]
    pub fn rand_with(rng: &mut impl rand::Rng) -> &'static str {
        use rand::seq::SliceRandom as _;

        // For now, only one option, so ez
        all().choose(rng).unwrap()
    }
}
#[cfg(feature = "three-usualcase")]
pub use usualcase::{
    all, AMY, BOB, CHO, DAN, EVE, FEY, GUY, HAN, IAN, JOE, KEN, LEA, MEL, NOA, ONI, PAM, QIN, RON, SAM, TIM, UWE, VIC, WES, XIN, YAS, ZOE,
};
#[cfg(all(feature = "rand", feature = "three-usualcase"))]
pub use usualcase::{rand as rand_usualcase, rand_with as rand_usualcase_with};

/// Defines the three-letter names in lowercase.
///
/// # Example
/// ```rust
/// use names::three::lowercase;
///
/// assert_eq!(lowercase::AMY, "amy");
/// assert_eq!(lowercase::DAN, "dan");
/// ```
#[cfg(feature = "three-lowercase")]
pub mod lowercase {
    /// Lowercase version of `Amy`.
    pub const AMY: &'static str = "amy";
    /// Lowercase version of `Bob`.
    pub const BOB: &'static str = "bob";
    /// Lowercase version of `Cho`.
    pub const CHO: &'static str = "cho";
    /// Lowercase version of `Dan`.
    pub const DAN: &'static str = "dan";
    /// Lowercase version of `Eve`.
    pub const EVE: &'static str = "eve";
    /// Lowercase version of `Fey`.
    pub const FEY: &'static str = "fey";
    /// Lowercase version of `Guy`.
    pub const GUY: &'static str = "guy";
    /// Lowercase version of `Han`.
    pub const HAN: &'static str = "han";
    /// Lowercase version of `Ian`.
    pub const IAN: &'static str = "ian";
    /// Lowercase version of `Joe`.
    pub const JOE: &'static str = "joe";
    /// Lowercase version of `Ken`.
    pub const KEN: &'static str = "ken";
    /// Lowercase version of `Lea`.
    pub const LEA: &'static str = "lea";
    /// Lowercase version of `Mel`.
    pub const MEL: &'static str = "mel";
    /// Lowercase version of `Noa`.
    pub const NOA: &'static str = "noa";
    /// Lowercase version of `Oni`.
    pub const ONI: &'static str = "oni";
    /// Lowercase version of `Pam`.
    pub const PAM: &'static str = "pam";
    /// Lowercase version of `Qin`.
    pub const QIN: &'static str = "qin";
    /// Lowercase version of `Ron`.
    pub const RON: &'static str = "ron";
    /// Lowercase version of `Sam`.
    pub const SAM: &'static str = "sam";
    /// Lowercase version of `Tim`.
    pub const TIM: &'static str = "tim";
    /// Lowercase version of `Uwe`.
    pub const UWE: &'static str = "uwe";
    /// Lowercase version of `Vic`.
    pub const VIC: &'static str = "vic";
    /// Lowercase version of `Wes`.
    pub const WES: &'static str = "wes";
    /// Lowercase version of `Xin`.
    pub const XIN: &'static str = "xin";
    /// Lowercase version of `Yas`.
    pub const YAS: &'static str = "yas";
    /// Lowercase version of `Zoe`.
    pub const ZOE: &'static str = "zoe";


    /// Lists all lowercase names in this module.
    ///
    /// # Returns
    /// A `'static` slice of [`&static str`](str)s that list all the names.
    #[inline]
    pub const fn all() -> &'static [&'static str] {
        &[AMY, BOB, CHO, DAN, EVE, FEY, GUY, HAN, IAN, JOE, KEN, LEA, MEL, NOA, ONI, PAM, QIN, RON, SAM, TIM, UWE, VIC, WES, XIN, YAS, ZOE]
    }



    /// Selects a random name out of all three-letter lowercase names.
    ///
    /// # Returns
    /// A [`&'static str`](str) that refers to a random constant in this crate.
    ///
    /// # Example
    /// ```rust
    /// use names::three::lowercase::rand;
    ///
    /// // Could print any of the `amy`, `bob`, `cho`, ... names!
    /// println!("{}", rand());
    /// ```
    #[cfg(feature = "rand")]
    #[inline]
    pub fn rand() -> &'static str { rand_with(&mut rand::thread_rng()) }

    /// Selects a random name out of all three-letter lowercase names using a provided Random Number Generator (RNG).
    ///
    /// # Arguments
    /// - `rng`: The random number generator (as an [`Rng`]) to use.
    ///
    /// # Returns
    /// A [`&'static str`](str) that refers to a random constant in this crate.
    ///
    /// # Example
    /// ```rust
    /// use names::three::lowercase::rand_with;
    ///
    /// // Could print any of the `amy`, `bob`, `cho`, ... names!
    /// println!("{}", rand_with(&mut rand::thread_rng()));
    /// ```
    #[cfg(feature = "rand")]
    #[inline]
    pub fn rand_with(rng: &mut impl rand::Rng) -> &'static str {
        use rand::seq::SliceRandom as _;

        // For now, only one option, so ez
        all().choose(rng).unwrap()
    }
}
#[cfg(all(feature = "rand", feature = "three-lowercase"))]
pub use lowercase::{rand as rand_lowercase, rand_with as rand_lowercase_with};





/***** RANDOM FUNCTIONS *****/
/// Selects a random name out of \*all\* available three-letter names (including UPPERCASE, Usualcase and lowercase).
///
/// Note that this dependent on which features are given. For example, if only the `three-uppercase`-feature is given,
/// this will only return uppercase names.
///
/// # Returns
/// A [`&'static str`](str) that refers to a random constant in this crate.
///
/// # Example
/// ```rust
/// use names::three::rand;
///
/// // Could print any of the `AMY`, `Bob`, `cho`, ... names!
/// println!("{}", rand());
/// ```
#[cfg(all(feature = "rand", any(feature = "three-uppercase", feature = "three-usualcase", feature = "three-lowercase")))]
#[inline]
pub fn rand() -> &'static str { rand_with(&mut rand::thread_rng()) }

/// Selects a random name out of \*all\* available three-letter names (including UPPERCASE, Usualcase and lowercase) using a provided Random Number Generator (RNG).
///
/// Note that this dependent on which features are given. For example, if only the `three-uppercase`-feature is given,
/// this will only return uppercase names.
///
/// # Arguments
/// - `rng`: The random number generator (as an [`Rng`]) to use.
///
/// # Returns
/// A [`&'static str`](str) that refers to a random constant in this crate.
///
/// # Example
/// ```rust
/// use names::three::rand_with;
/// use rand::thread_rng;
///
/// // Could print any of the `AMY`, `Bob`, `cho`, ... names!
/// println!("{}", rand_with(&mut thread_rng()));
/// ```
#[cfg(all(feature = "rand", any(feature = "three-uppercase", feature = "three-usualcase", feature = "three-lowercase")))]
#[inline]
pub fn rand_with(rng: &mut impl rand::Rng) -> &'static str {
    use rand::seq::IteratorRandom as _;

    // Construct a list of slices to take into account
    let mut sets: Vec<&'static [&'static str]> = vec![];
    #[cfg(feature = "three-uppercase")]
    sets.push(uppercase::all());
    #[cfg(feature = "three-usualcase")]
    sets.push(usualcase::all());
    #[cfg(feature = "three-lowercase")]
    sets.push(lowercase::all());

    // Take a random iterator sample on the flattened iterator
    // SAFETY: The unwrap() is OK because we guarantee statically the slices are populated, and the feature gates assert that at least one set is present.
    sets.into_iter().map(|s| s.iter()).flatten().choose(rng).unwrap()
}