MCPcopy Create free account
hub / github.com/bedroombuilds/python2rust / main

Function main

06_pattern_matching/rust/fizzbuzz.rs:1–22  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1fn main() {
2 fn if_buzz(x: i32) {
3 if x % 15 == 0 {
4 println!("FizzBuzz")
5 } else if x % 3 == 0 {
6 println!("Fizz")
7 } else if x % 5 == 0 {
8 println!("Buzz")
9 } else {
10 println!("{}", x)
11 }
12 }
13
14 let fizz_buzz = |x| match (x % 3, x % 5) {
15 (0, 0) => println!("FizzBuzz"),
16 (0, _) => println!("Fizz"),
17 (_, 0) => println!("Buzz"),
18 (_, _) => println!("{}", x),
19 };
20
21 (1..24).into_iter().for_each(fizz_buzz);
22}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected