Improve Rust code

This commit is contained in:
Lavender 2021-04-16 23:49:20 -07:00
parent 5d6299f71b
commit 82faaa8082
Signed by: endie
GPG key ID: CC5162D7C2146F01

View file

@ -2,9 +2,9 @@ fn main() {
let buzzes = [(3, "Fizz"), (5, "Buzz")];
for i in 1..101 {
let output = (0..buzzes.len()).fold(String::new(), |string, j| {
if i % buzzes[j].0 == 0 {
string + buzzes[j].1
let output = buzzes.iter().fold(String::new(), |string, buzz| {
if i % buzz.0 == 0 {
string + buzz.1
} else {
string
}