3 ms·
> This style is enforced by warnings for important types, such as errors. How do you inform the compiler that a type is important? You might not be using the s
by kenko 13y ago
> This style is enforced by warnings for important types, such as errors.
How do you inform the compiler that a type is important? You might not be using the standard Result type.
- pcwalton 13y agoYou use an attribute, "#[must_use]". I haven't seen code not use the standard Result type, and I don't think it's likely. First of all, it's generic, so you aren't forced into a set of errors or an interface that you have to conform to—there's no reason not to use it. Second, there's strong pressure to use Result: all of the standard libraries use that type, so you'd have to write a lot of code to convert back and forth between your own error type and Result if you wanted to create your own for some reason. It'd also be less convenient from an import point of view: you'd always have to import your custom Result everywhere, whereas Result is always available right there in the prelude. Plus, you get really convenient "try!" macro sugar if you use Result. All of this means that you'd really have to go out of your way to not use Result, and my experience matches this.