faker_rust/default/
cosmere.rs1use crate::base::sample;
4use crate::locale::fetch_locale;
5
6pub fn character() -> String {
8 fetch_locale("cosmere.characters", "en")
9 .map(|v| sample(&v))
10 .unwrap_or_else(|| sample(FALLBACK_CHARACTERS).to_string())
11}
12
13pub fn location() -> String {
15 fetch_locale("cosmere.locations", "en")
16 .map(|v| sample(&v))
17 .unwrap_or_else(|| sample(FALLBACK_LOCATIONS).to_string())
18}
19
20pub fn book() -> String {
22 fetch_locale("cosmere.books", "en")
23 .map(|v| sample(&v))
24 .unwrap_or_else(|| sample(FALLBACK_BOOKS).to_string())
25}
26
27const FALLBACK_CHARACTERS: &[&str] = &[
29 "Kaladin", "Shallan", "Dalinar", "Vin", "Kelsier", "Elend", "Sazed",
30 "Raoden", "Hrathen", "Siri", "Vivenna", "Lightsong", "Waxillium", "Wayne",
31 "Marasi", "Shai", "Hoid", "Adolin", "Navani", "Jasnah", "Renarin",
32];
33
34const FALLBACK_LOCATIONS: &[&str] = &[
35 "Roshar", "Scadrial", "Sel", "Nalthis", "Taldain", "Threnody", "First of the Sun",
36 "Yolen", "Braize", "Ashyn", "Rosharan System", "Scadrian System",
37];
38
39const FALLBACK_BOOKS: &[&str] = &[
40 "The Way of Kings", "Words of Radiance", "Oathbringer", "Rhythm of War",
41 "Mistborn: The Final Empire", "The Well of Ascension", "The Hero of Ages",
42 "The Alloy of Law", "Shadows of Self", "The Bands of Mourning",
43 "Elantris", "Warbreaker", "Arcanum Unbounded", "Elantris",
44];
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn test_character() {
52 assert!(!character().is_empty());
53 }
54
55 #[test]
56 fn test_location() {
57 assert!(!location().is_empty());
58 }
59
60 #[test]
61 fn test_book() {
62 assert!(!book().is_empty());
63 }
64}