Iterating over the Rational Numbers with Rust

Functional Pearl: Enumerating the Rationals is a paper that's been on my "to-read" list for a long time. I finally got around to reading it recently, and ended up implementing the algorithm it describes and publishing it as a crate.

This article briefly describes the paper and some of the Rust-specific details of the implementation I arrived at.

The Algorithm

The paper describes an algorithm which, starting from a base case, iterates through every possible rational number. The algorithm is interesting because:

The Implementation

Generic Numeric Traits

Directly implementing Iterator


I didn't have a particular