Closed FrankKair closed 6 years ago
004
Instead of type annotating a constant, I let the compiler infer the type by giving collect a type.
collect
// Then let reversed: String = n.to_string().chars().rev().collect(); // Now let reversed = n.chars().rev().collect::<String>();
036
Uses a function with pattern matching to call a general palindrome check function.
fn number_palindrome(n: i32, base: i8) -> bool { match base { 2 => palindrome(format!("{:b}", n)), 10 => palindrome(n.to_string()), _ => false, } }
Refactor
004
Instead of type annotating a constant, I let the compiler infer the type by giving
collect
a type.036
Uses a function with pattern matching to call a general palindrome check function.