Skip to main content

Builder

Trait Builder 

Source
pub trait Builder: Any {
    type From;
    type To;

    // Required methods
    fn new(value: Self::From) -> Self;
    fn build(self) -> Self::To;
}
Expand description

§Builder trait

Builder trait is a trait to builder pattern

Although there are few methods that need to be implemented uniformly in this trait, it exists as a specification

Required Associated Types§

Required Methods§

Source

fn new(value: Self::From) -> Self

§From target to builder

consume the target and return the builder

§Attention
  • default use Self::default() to create a new builder if the builder has no parent
  • if the builder has a parent, you need to implement the method to create a new builder
Source

fn build(self) -> Self::To

§Build the target

consume the builder and return the target

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§