3 ms·
Rust does not have constructors as a language feature like that, and you must fully initialize objects, unless you use unsafe.
by steveklabnik 9y ago
Rust does not have constructors as a language feature like that, and you must fully initialize objects, unless you use unsafe.
- golergka 9y agoWouldn'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.