Closed kugland closed 1 year ago
This can actually be done by using #[builder(build_fn(error = "Infallible"))]
, which the compiler will accept as long as there are no fields without a default value.
What would be cool is if it somehow possible to have builder constructor function to enforce an invariant on required fields. E.g. instead of having default() and fallable build() to have new(required_field1, ...) and infallible build as a consequence
I find myself wanting to handroll a builder just for this feature as it tend to pollute the code with error handling where it can be avoided with just enforcing proper invariants on the builder itself
Addressed in #227
When all fields have defaults and there is no validation function, the
build()
function is effectively infallible. Is it possible forbuild()
to returnResult<T, Infallible>
in this case, or justT
?