Discussion about this post

User's avatar
cauldron's avatar

Great article!

`From` for infallible conversions and `TryFrom` for fallible ones.

PS: Oh, I just needed to read on.

Expand full comment
Sam's avatar

Enjoyed this post! I think you've missed out the most basic one though, which is to declare every field as`pub` and use the raw struct syntax to make new objects. Especially for simple parameter list structs which implement Default, I much prefer to skip the builder pattern and use

```

Struct {

field1: "value",

field2: 3224,

field3: Enum::Variant,

..Default::default()

}

```

You miss out on encapsulation etc but for simple cases where it's clear you don't need it, this is super low maintenance

Expand full comment
4 more comments...

No posts