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

Mandatory via_mutators field without default

Open vladislav-tkach opened this issue 5 months ago • 0 comments

I need some kind of nice API wrapper of a SQL query builder for multiple dynamically constructed queries I use. They are similar but quite huge, therefore I want a more concise way of using them. typed_builder is a nice fit, however it lacks one feature I would appreciate.

The queries mostly differ in what I SELECT from the same FROM, so I used an enum to specify what I want to select.

enum QueryType {
    Count, // select count of all entries
    Some,  // select with a limit
    One,   // select a single entry
}

And in query builder wrapper I'd like to have a filed of this enum that is not default (to have to specify explicitly what to select) and that is also via_mutators (to have nicer syntax like .select_some() instead of .query_type(QueryType::Some). But currently (0.21.0) via_mutators requires the field's type to implement Default.

Thanks for the great crate and please let me know if I miss anything.

vladislav-tkach avatar Jun 04 '25 09:06 vladislav-tkach