Function synstructure::unpretty_print [] [src]

pub fn unpretty_print<T: Display>(ts: T) -> String

Dumps an unpretty version of a tokenstream. Takes any type which implements Display.

This is mostly useful for visualizing the output of a procedural macro, as it makes it marginally more readable. It is used in the implementation of test_derive! to unprettily print the output.

Stability

The stability of the output of this function is not guaranteed. Do not assert that the output of this function does not change between minor versions.

Example

assert_eq!(
    synstructure::unpretty_print(quote! {
        #[allow(non_upper_case_globals)]
        const _DERIVE_krate_Trait_FOR_A: () = {
            extern crate krate;
            impl<T, U> krate::Trait for A<T, U>
            where
                Option<U>: krate::Trait,
                U: krate::Trait
            {
                fn a() {}
            }
        };
    }),
    "# [
    allow (
        non_upper_case_globals )
    ]
const _DERIVE_krate_Trait_FOR_A : (
    )
= {
    extern crate krate ;
    impl < T , U > krate :: Trait for A < T , U > where Option < U > : krate :: Trait , U : krate :: Trait {
        fn a (
            )
        {
            }
        }
    }
;
"
)