rust-typed-builder icon indicating copy to clipboard operation
rust-typed-builder copied to clipboard

Allow invariant checks in `.build()`

Open Banyc opened this issue 2 years ago • 10 comments

I want something like this:

pub struct S {
    x: i32,
    y: i32,
}

impl S {
    fn check_rep(&self) {
        assert!(self.x < self.y);
    }
}

When .build() is called, I also want check_rep to be called.

Banyc avatar May 22 '22 07:05 Banyc