Exercism: Rust version of the 'Raindrops' exercise.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
265 B

3 years ago
  1. pub fn raindrops(n: u32) -> String {
  2. let mut res = String::new();
  3. if n % 3 == 0 { res.push_str("Pling"); }
  4. if n % 5 == 0 { res.push_str("Plang"); }
  5. if n % 7 == 0 { res.push_str("Plong"); }
  6. if res.is_empty() { return n.to_string() }
  7. res
  8. }