3 ms·
There's no notion of (default) constructors in Rust? How do you build complex objects in it?
by pbsd 13y ago
There's no notion of (default) constructors in Rust? How do you build complex objects in it?
- masklinn 13y agoThe same way you do in other struct-based languages I expect, either build the struct directly or go through a static factory function.
- smosher 13y agoI admit this tripped me up for a minute. After blinking a few times, I realized that any object that's difficult to initialize manually is going to be a constructor provided for it anyway. But, see also: the Zero trait Patrick mentioned, which can be derived.