show icon indicating copy to clipboard operation
show copied to clipboard

Results and Iterator patterns

Open mre opened this issue 7 years ago • 1 comments

What?

Describe some useful patterns when iterating over Result types.

Why?

Working with an iterator of Results (i.e. Iterator<Item = Result<O, E>>) can be a bit of a hassle for beginner and intermediate Rust programmers. When collecting the result of the iteration into a variable, the main question is, what shall be the resulting datatype?

  • All Oks?
  • All Errors?
  • The first Error?
  • The first Ok?
  • Something else?

How?

Show some patterns from Iteration patterns for Result & Option. Show usage of a library for that, e.g. resiter

mre avatar Feb 23 '18 10:02 mre

This is one I'd definitely love to see. As a rust beginner, idiomatic usage of iterators and result types is a stumbling block. Also, although it may be outside of the scope of this specific issue, when to use .iter() vs .iter_mut() vs .into_iter() is confusing, and it'd be cool to see examples of when each of these is recommended.

dudelson avatar Oct 23 '18 23:10 dudelson