Skip to content

Commit af4cbbe

Browse files
committed
code for 0x0f Debugging
1 parent 0b673fe commit af4cbbe

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

0f_debugging/rust/fizzbuzz.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
fn fizz_buzz(x: i32) -> String {
2+
match (x % 3, x % 5) {
3+
(0, 0) => "FizzBuzz".into(),
4+
(0, _) => "Fizz".into(),
5+
(_, 0) => "Buzz".into(),
6+
(_, _) => format!("{}", x),
7+
}
8+
}
9+
10+
fn vec_fizz_buzz(n: i32) -> Vec<String> {
11+
let mut v = Vec::new();
12+
for i in 1..(n + 1) {
13+
v.push(dbg!(fizz_buzz(i)));
14+
}
15+
v
16+
}
17+
18+
fn main() {
19+
println!("{:?}", vec_fizz_buzz(1));
20+
}

0 commit comments

Comments
 (0)