Derive Macro teloc::Dependency [−][src]
#[derive(Dependency)]
{
// Attributes available to this derive:
#[init]
}
Expand description
Derive macro can be used on structs with named fields when all fields implements Dependency
trait or
fields described using #[init(...)]
attr.
We do not recommend using this macro in production code.
By default macro define all fields as dependencies, but you can initialize field by yourself
using attribute #[init]
. In curly braces you must define a parameters, that will be passed
to calling FieldType::init
method.
Example:
ⓘ
use teloc::Dependency;
struct Number(u8);
impl Number {
fn init(number: u8) -> Self { Number(number) }
}
#[derive(Teloc)]
struct Foo {
#[init(5)]
a: Number
}
#[derive(Teloc)]
struct Bar {
foo: Foo,
}