Follow

If you're defining an alias for your crate's Result type, instead of:

type Result<T> = std::result::Result<T, MyError>;

use:

type Result<T, E = MyError> = std::result::Result<T, E>;

This still works as `Result<()>`, but doesn't cause errors when someone accidentally shadows std's Result with it. It also makes Rustdoc display the error type explicitly in the documentation.

· · Web · 0 · 7 · 15
Sign in to participate in the conversation
Octodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!