[][src]Function extended_fizzbuzz::fizzbuzz

pub fn fizzbuzz(
    from: usize,
    to: usize,
    matchers: &Vec<Matcher>
) -> Result<(), FizzBuzzError>

Provides a configurable version of FizzBuzz.

Parameters

With from and to you can define the number area for which to run the operation. Both of these values are inclusive. This means that if you specify 1 and 10, the numbers for which output is produced are: 1,2,3,4,5,6,7,8,9,10

With matchers you can provide some matcher::Matchers. These are used to configure how numbers are substituted with words. The matchers are tested in the order of the vector.

Errors

  • Returns FizzBuzzError::FromBiggerThanTo, if the from parameters value is bigger than the to parameters value.

Example

use extended_fizzbuzz::{fizzbuzz, Matcher};

let matchers = vec![
    Matcher::new(3, "Fizz").unwrap(),
    Matcher::new(5, "Buzz").unwrap(),
];

assert!(fizzbuzz(1, 10, &matchers).is_ok());
assert!(fizzbuzz(10, 1, &matchers).is_err());