Skip to main content

builder

Attribute Macro builder 

Source
#[builder]
Expand description

A piece’s builder trait, generated from the inherent impl that holds its builder methods (docs/api-style.md “Typed builders and erasure”).

ⓘ
#[day::builder(RatingBuilder)]
impl Rating {
    /// The number of stars.
    pub fn max(mut self, n: u32) -> Self { self.max = n; self }
    pub fn editable<M>(mut self, on: impl IntoReactive<bool, M>) -> Self { … }
}

The block is emitted unchanged, followed by pub trait RatingBuilder: Sized declaring every pub fn …(self, …) -> Self of the block, impl RatingBuilder for Rating, and impl<Inner: RatingBuilder + Piece> RatingBuilder for Decorated<Inner>, so rating(v).padding(8.0).max(10) resolves. A trait that carries one of the impl’s type parameters names it: #[day::builder(NavBuilder<K>)] on impl<K: Route, S: Binding<K>> Nav<S, K> copies K: Route onto the trait. Decorated and Piece must be in scope.