About 7,830,000 results
Open links in new tab
  1. rust - How do I stop iteration and return an error when …

    Here's an example for the specific case where the .map() operations are nested. The problem it solves is how to propagate a failure from the innermost closure while avoiding using .unwrap() …

  2. rust - What is the idiomatic way to do something when an Option …

    Jan 26, 2022 · As Lukas suggested, the map_or method can also be used. Note that arguments passed to are eagerly evaluated, so if performance is critical, you might want to consider …

  3. rust - How to use a map over vectors? - Stack Overflow

    203 Rust likes to be more general than that; mapping is done over iterators, rather than over solely vectors or slices. A couple of demonstrations:

  4. rust - How to use async/await inside closure of `Option::and_then` …

    Nov 4, 2021 · If, on the other hand, I use an async block, the closure would return impl Future<Output = Option<_>> which is not allowed because Option::and_then only allows …

  5. Understanding filter_map in rust - Stack Overflow

    Jun 12, 2020 · I am trying to get ages of all Person who has some second name. I was able to do it using filter and map separately as below, But I am wondering if we can use filter_map in rust. …

  6. How to iterate through a Hashmap, print the key/value and …

    Aug 17, 2017 · Rust is preventing you from mutating the map while you are iterating over it. In most languages this is allowed, but often the behaviour is not well-defined, and removal of the …

  7. rust - What's the most idiomatic way of working with an Iterator of ...

    Apr 2, 2016 · 16 You can implement these iterators yourself. See how filter and map are implemented in the standard library. map_ok implementation: rust

  8. rust - error handling, map_err and error type conversion - Stack …

    Jan 2, 2022 · 8 map_err is returning a Result<i64, ParsePosNonzeroError> but you're trying to affect it to x, which you declared as an i64 variable. You need to add a ? so that an Err result …

  9. rust - How to map over only the Some () values in an iterator?

    Oct 1, 2020 · How to map over only the Some () values in an iterator? Asked 5 years ago Modified 5 years ago Viewed 7k times

  10. In Rust `map_or` and `map_or_else` method of `Option`/`Result`, …

    Sep 20, 2022 · map_or takes a value, this means the "or" has to be evaluated before the method is even called, that is in a.map_or(b, fn) Rust has to first fully evaluate a and b before it can …