Re:Dark side of ergonomics in Rust
by steveklabnik on Saturday April 14, 2018 @01:22PM
(#16838291)
Rust does not have constructors as a language feature like that, and you must fully initialize objects, unless you use unsafe.
[ Parent
| on HN ]
Wouldn't you want, in a similar manner, a single create() call to be responsible for full initialization? An API that makes it possible to have entities half-initialzed looks like a design mistake to me. If an initialization is long and requires a lot of parameters, I personally split a "config" object that has easy access to all of them and the "real" object that swallows it in constructor or "create" call all at once.