rust-unofficial / patterns

A catalogue of Rust design patterns, anti-patterns and idioms
https://rust-unofficial.github.io/patterns/
Mozilla Public License 2.0
8.11k stars 375 forks source link

Collecting into a Result or Option #24

Open lambda-fairy opened 8 years ago

lambda-fairy commented 8 years ago

The .collect() instance for Result and Option is pretty useful, but is often overlooked by newcomers. I'd like to see an article that describes it.

adaszko commented 7 years ago

Writing explicit Ok(...) or Some(...) respectively has the advantage of being more explicit but otherwise equivalent.