Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Default, Debug)]
- struct Options {
- a: i32,
- b: i32,
- c: i32,
- d: i32,
- e: f64,
- }
- impl Options {
- fn with_a(self, a: impl Into<i32>) -> Self {
- Self {
- a: a.into(),
- .. self
- }
- }
- fn with_e(self, e: impl Into<f64>) -> Self {
- Self {
- e: e.into(),
- .. self
- }
- }
- }
- fn main() {
- let opts = Options::default().with_a(1).with_e(2.0);
- println!("{:?}", opts);
- }
Add Comment
Please, Sign In to add comment