Derive Macro partial_ref_derive::PartialRefTarget
source · #[derive(PartialRefTarget)]
{
// Attributes available to this derive:
#[part]
}
Expand description
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:
ⓘ
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,
}