Skip to content
Learning basic Rust via variations on the FizzBuzz game.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

My Public GitHub Page Is Here My Website Is Here

Fizz Buzz Variations in Rust

Exploring the FizzBuzz Game as an exercise in learning the Rust Language I came up with four solutions exhibited here along with a development version containing some initial exploration.

If you haven't tried solving the FizzBuzz Game before, you might want to try solving it in your favorite language and perhaps also explore Rust a bit before looking at these SPOILERS.

In reverse chronological order these are:

File Technique heap-allocated closures cyclic iterators with if let cyclic iterators with match mutable structures early exploration and false starts

My first idea was to use closures. I didn't know enough to make that work until I'd found the other solutions. I was delighted when I found the trick of creating cyclic iterators using standard components.

I would love to find a flexible approach that didn't require so much mutability without incurring the usual overhead of using the mod operator or growing the heap. Tail Call Optimization would help but Rust doesn't offer that yet.

J. Greg Davidson, Thursday, 30 April 2015

You can’t perform that action at this time.