colin-kiegel / rust-derive-builder

derive builder implementation for rust structs
https://colin-kiegel.github.io/rust-derive-builder/
Apache License 2.0
1.32k stars 88 forks source link

Please advise: toBuilder functionality #316

Closed wcarmon closed 7 months ago

wcarmon commented 7 months ago

What's the best way to go from an instance to a new builder?

Use case: given a struct with 30 fields, create a new struct with one field changed and go thru the validation again.

In the old world (read Java), we would do something like foo1.toBuilder().field(newValue).build()

https://projectlombok.org/features/Builder

wcarmon commented 7 months ago

Possible duplicate of https://github.com/colin-kiegel/rust-derive-builder/issues/170

Comment here seems related

Perhaps this is more of a documentation issue (as opposed to code change)

TedDriggs commented 7 months ago

I don't know that a documentation change is needed here; Rust has a canonical way to do this (discussed in the linked comment), it's not something that many people using builders seem to need to do, and the crate doesn't provide any special support for it.

wcarmon commented 7 months ago

Docs would save you from having the same discussion repeatedly.

From the issue history, it looks like you've had to respond to this several times.

TedDriggs commented 7 months ago

I’d be happy to review a PR with a proposed docs amendment on it.