Attribute Macro struct_merge_ref

Source
#[struct_merge_ref]
Expand description

Implement the struct_merge::StructMergeRef<S> trait for all given targets.

All fields to be merged must implement the [std::clone::Clone] trait.

Eiter a single struct or a list of structs can be provided. StructMergeRef<T> will then be implemented on each given target struct.

Examples:

  • #[struct_merge_ref(crate::structs::Target)]
  • #[struct_merge_ref([crate::structs::Target, crate:structs::OtherTarget])]

The targets struct paths have to be

  • absolute
  • relative to the current crate
  • contained in this crate

struct.rs

use struct_merge::struct_merge_ref;

pub struct Target {
    pub test: String,
}

pub struct OtherTarget {
    pub test: String,
}

#[struct_merge_ref([crate::structs::Target, crate:structs::OtherTarget])]
pub struct Test {
    pub test: String,
}