1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } } pub fn tr(index: usize, lang: String) -> String { let fr = ["bonjour", "tout", "le monde"]; let en = ["hello", "all", "the world"]; if index >= fr.len() { return String::from("Not Found"); } if lang == "fr" { String::from(fr[index]) } else { String::from(en[index]) } }