A New Design for Pretty Printer Implementations in Rust
Academic research on pretty printing typically assumes garbage-collected functional languages, making direct translation to Rust non-trivial. I propose a trait-based design for pretty printer document trees that preserves the expressiveness of Wadler-style layouts while aligning with Rust's ownership model. A proof-of-concept implementing the globally optimal algorithm from A pretty expressive printer achieves a 60× speedup over the reference Rust implementation and competitive performance with the ecosystem's leading pretty printer crates.