Skip to main content

Pretty

Derive Macro Pretty 

Source
#[derive(Pretty)]
{
    // Attributes available to this derive:
    #[pprint]
}
Expand description

Derive the Pretty trait for a struct or enum

This macro will generate a From implementation for the given struct or enum. The generated From implementation will convert the struct or enum into a pprint::Doc<’a>, where the Doc lifetime is either the lifetime of the struct or enum, or ’a if no lifetime is specified. Example:

use pprint::Doc;
use pprint_derive::Pretty;
#[derive(Pretty)]
struct Hey {
    a: u32,
    b: u32,
}
let hey = Hey { a: 1, b: 2 };
let doc: Doc = hey.into();