Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't think it's bad thing. In fact one of my favorite features is that you can do `.collect::<Result<Vec<_>, _>>()` to turn an interators of Results, into a Result of just the Vec if all items succeed or the first error. That is a feature you just can't express in Python.

But you have to admit that is a pretty noisy line that could be difficult to parse.



Then don't write it that way.

   let new_array: Vec<usize> = array.into_iter()
        .filter(|&x| x != 0)
        .map(|x| x * 2)
        .collect();
Isn't so bad.


I believe I have the habit of putting it on the end because the final type might be different. Consider:

    let array = ["DE", "AD", "BE", "EF"];
    let new_array: Vec<u32> = array.into_inter()
      .map(|x| u32::from_str_radix(x, 16))
      .collect()?;
In this case you need to specify the Result generic type on generic. This has come up for me when working with Stream combinators. Most projects probably end up in needing some lifetime'd turbofish and you have to be able to parse them. They aren't rare enough, IME, to argue that Rust isn't noisy.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: