Trait Buildable

Source
pub trait Buildable: Sized
where Self: BoulderBase,
{ type Builder: Builder<Result = Self>; // Required method fn builder() -> Self::Builder; }
Expand description

A type that has an associated default Builder.

This trait is implemented via the Buildable derive macro. It cannot be directly implemented because the library itself provides a blanket implementation from a more complex underlying trait MiniBuildable, which is not currently documented.

This restriction may be removed in a future version; much of the complexity in this module stems from lacking generic associated types on stable.

Required Associated Types§

Source

type Builder: Builder<Result = Self>

A default choice of Builder for this type.

Required Methods§

Source

fn builder() -> Self::Builder

Create a new default builder.

Example

use boulder::{Builder, Buildable};

#[derive(Buildable)]
struct Foo {
   a: i32
}

let b = Foo::builder();
let f = b.build();
assert_eq!(f.a, 0);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> Buildable for T
where T: BoulderBase + MiniBuildable<<T as BoulderBase>::Base>,

Source§

type Builder = <T as MiniBuildable<<T as BoulderBase>::Base>>::Builder