[][src]Derive Macro partial_ref_derive::PartialRefTarget

#[derive(PartialRefTarget)]
{
    // Attributes available to this derive:
    #[part]
}

Derives instances of PartialRefTarget and associated traits.

Can only be used for structs. The attribute #[part(PartName)] can be used on the struct itself for an abstract part or on a field for a field part. Parts have to be declared separately. PartName can be any valid rust type that implements the Part trait. For fields the field type of the part has to match the actual type of the field.

Example:

This example is not tested
use partial_ref::{PartialRefTarget, part};

#[derive(PartialRefTarget)]
#[part(SomeAbstractPart)]
struct ExampleStruct {
    field_without_part: usize,
    #[part(SomeFieldPart)]
    a: usize,
    #[part(another_crate::AnotherFieldPart)]
    b: usize,
}

Instead of #[part(PartName)] it is also possible to use #[part = "PartName"] which was the only supported syntax in previous versions of this crate.