template-builder 0.1.0

A rust library for making idiomatic, declarative, builder-like patterns that use the struct literal syntax.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
pub trait Template {
    type Output;

    fn define(self) -> <Self as Template>::Output;
}

pub trait TemplateConstruction: /*FnOnce() + */ Default + Template {
    fn on_create(&mut self, f: impl FnOnce(&mut Self::Output) + 'static);
    fn create(self) -> Self::Output;
    fn build<O>(self, f: impl FnOnce(Self::Output) -> O) -> O;
}

pub trait Templatable {
    type New: Template<Output = Self>;
}