const_type_layout

Derive Macro TypeLayout

#[derive(TypeLayout)]
{
    // Attributes available to this derive:
    #[layout]
}
Available on crate feature derive only.
Expand description

Provides the #[derive(TypeLayout)] implementation for the const_type_layout::TypeLayout trait.

The derive also accepts a #[layout(...)] attribute to configure the implementation as follows:

  • #[layout(crate = "<crate-path>")] changes the path to the const-type-layout crate that the derive uses, which by default is const_type_layout.
  • #[layout(bound = "<where-predicate>")] adds the provided predicate to the where clause of the trait implementation.
  • #[layout(free = "<type>")] removes the the auto-added trait bounds for the type parameter <type> from the trait implementation, e.g. when implementing a wrapper around PhantomData<T> which should implement the trait for any T.