Expand description

An alternative Display impl for proc_macro, respecting the input layout and formatting.

The idea is that the impl of Display for proc_macro types doesn’t respect the input’s layout. For most commun Rust use cases, this is okay, because the language doesn’t depend on whitespaces and has its own grammar for floating point numbers, field access, etc. However, for all other use cases, you will lose your formatting and indentation. Plus, some EDSLs might require strict use of newlines or symbols with a leading colon, comma, etc. without whitespaces.

This crate provides an implementation of Display that respects the input’s formatting, so that one can display a TokenStream and parse it with a more esoteric parser than syn.

Currently, this crate highly depends on nightly features. You cannot use it on the stable channel… just yet.

You can get a faithful Display object by calling the faithful_display function on your TokenStream.

At the time of writing, traits don’t allow existential impl Trait to be used in methods. This is unfortunate, then the feature is accessed through a function instead of a method.

Traits

A more faithful Display.

Functions

Create a Display object out of a TokenStream that respects as closely as possible its formatting.