// In impl Ident {}
// `Interner` just stores a bunch of Strings
fn pretty_print(&self, f: &mut fmt::Formatter, intern: &Interner> -> fmt::Result {
...
}
Given that this function takes a fmt::Formatter and returns fmt::Result, I feel like there should be some way for std to interact with it but I can't find anything on the docs about that.
This is a nice pattern, which would be made even nicer if Rust had a way to coerce closures directly into single-method impl Traits, Java-style. If there's a need to do this for several types, one could write a from_fn method to turn a closure into a Display type, the same way there's std::iter::from_fn for creating ad hoc iterators: