tracks/rust/exercises/diamond/example.rs in trackler-2.2.1.146 vs tracks/rust/exercises/diamond/example.rs in trackler-2.2.1.147
- old
+ new
@@ -1,11 +1,10 @@
static ABC: &'static str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-use std::ascii::AsciiExt;
pub fn get_diamond(diamond_char: char) -> Vec<String> {
let mut result: Vec<String> = Vec::new();
- let diamond_char = AsciiExt::to_ascii_uppercase(&diamond_char);
+ let diamond_char = diamond_char.to_ascii_uppercase();
if ABC.find(diamond_char).is_none() {
return result;
}
if diamond_char == 'A' {
return vec![String::from("A")];
@@ -22,10 +21,9 @@
//build second half
let mut rev = result.clone();
rev.pop(); //remove middle pice to avoid duplicates
for line in rev.drain(..).rev() {
result.push(line);
-
}
result
}