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

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.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: