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

initialize builder from existing struct instance #290

Closed t-nil closed 1 year ago

t-nil commented 1 year ago

Hello,

I just discovered derive_builder, and for me it seems a common use case to initialize a builder with an existing struct before modifying some fields, like the struct update syntax mentioned here.

E.g., is a syntax like

let s1: Struct = […];
// …
StructBuilder::from_struct(s1).field1(…).field2(…);

analogous to pure rust

let s1: Struct = […];
// …
let s2 = Struct {
field1: […],
field2: […],
..s1
}

already possible or planned for the future?

Thanks for your time!

PS: I am quite new to rust, maybe I am overlooking something.

TedDriggs commented 1 year ago

Duplicate of #170