| ▲ | tialaramex 5 hours ago | |
Rust has a Default trait, if your type Goose has a Default then let foo: Goose = Default::default(); Those "primitive" types have a Default, the integers default to zero, as do the floating point types, bool defaults to false, I believe an empty string is the default string (in both the sense that's the default for String, and the default for str, the string slice reference roughly analogous to C++ string_view) Some things don't have a sane default, just as those things wouldn't provide a zero argument constructor in C++. There isn't a default file descriptor, a default network socket, and so on and so those types do not implement Default | ||
| ▲ | quietbritishjim 3 hours ago | parent [-] | |
That makes sense, thanks! | ||