#fizzbuzz #iterator #fb #over-engineered #paramater #vezz #paramaters

bin+lib over-engineered-fizzbuzz

An over-engineered FizzBuzz implementation

2 releases

0.1.1 Jan 26, 2023
0.1.0 Jan 26, 2023

#1 in #fizzbuzz

MIT/Apache

12KB
166 lines

Over-Engineered-FizzBuzz.

An over-engineered FizzBuzz implementation.

Usage

  • Use as an iterator
for i in (1..=5).fizzbuzz() {
    println!("{i}");
}

/* OUTPUT
1
2
Fizz
4
Buzz
*/
  • Add Paramater
let mut fb = FizzBuzz::default();

fb = fb + ("Kazz", 7);
fb += ("Vezz", 11);

let left = fb.compute(3 * 5 * 7 * 11);
let right = "FizzBuzzKazzVezz";

assert_eq!(left, right);
  • Give custom paramaters
let fb = FizzBuzz::from(vec![("Carl", 3), ("Wheezer", 4)]);

let left = (1..=5).fizzbuzz_custom(fb).collect::<Vec<String>>();
let right = ["1", "2", "Carl", "Wheezer", "5"];

assert_eq!(left, right);
  • Basic implementation
let fb = FizzBuzz::default();

for i in 1..100 {
    let res = fb.compute(i);
    println!("{res}");
}

No runtime deps