Derive Macro depends::derives::Dependencies

source ·
#[derive(Dependencies)]
Expand description

Mark this type as a set of dependencies for a DerivedNode.

For a single dependency, see the Dependency type.

This will generate 2 types:

  • MyTypeDep: A generic struct which can be constructed from any set of nodes who’s output corresponds to the fields of the base type.
  • MyTypeRef<'_>: A read-only reference to all of the fields of the generic type above.

Note that you will not use the type annotated by this macro directly. It is merely an instruction to generate the above types.

Usage

// Use this type to express the _types_ of output to depend on. It won't
// actually be _used_ at runtime. See below.
#[derive(Dependencies)]
struct TwoNumbers {
   left: NumberValue,
   right: NumberValue,
}

// Generates:
// A generic struct which can be constructed from _any_ nodes who's
// output is a [NumberValue].
// TwoNumbersDep<A, B> {
//   left: A,
//   right: B,
// }
// A read-only reference to all of the fields of the generic type above.
// TwoNumbersRef<'a> {
//   left: Ref<'a, NumberValue>,
//   right: Ref<'a, NumberValue>,
// }