You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was previously discussed in #170. I am still not inclined to pursue this, as Rust provides efficient struct-update syntax in the following form:
let user_with_alt_id = User{id:"...".into(),
..old_user
};
Additionally, there are too many open questions about the exact behavior of such a method to generate an implementation - including, but not limited to:
Does this method invoke the setters of the builder with the values from the input struct, or directly initialize the fields? Since setters may have custom behavior, this decision could have externally-visible side-effects.
What happens to fields from the struct that are skipped in the builder? Their values will be lost; is this expected by the person using the method?
Does this method consume the input struct? In idiomatic Rust, the answer would be "yes", but the naming in this example suggests that you'd prefer it instead implicitly clone the fields.
Given the number and severity of questions that don't have clear answers, it's best for authors wishing to provide this functionality to hand-build this method themselves for the structs where there's a good reason for it.
It would be great to have the ability to create a builder from the related struct.
Something like
The text was updated successfully, but these errors were encountered: