.unwrap().unwrap().into::<&&&Vec<Box<&&&&&mut String>>>()
which kind of ruins the elegance :PThe Rust and Python code are not equivalent: The Python code instantly produces the nested list. Rust map does not iterate over the list given to it, it only produces an iterator that you then have to drain. To make them equivalent, you need to add collect calls.
... which adds more typing, because then collect needs to know the types you want to collect into. To make the Rust code fully equivalent with the Python version, you need to do:
let words_on_lines: Vec<Vec<&str>> = text.lines().map(|line| line.split_whitespace().collect()).collect();
// alternatively, you can put the type arguments into the .collect() calls:
let words_on_lines = text.lines().map(|line| line.split_whitespace().collect::<Vec<_>>()).collect::<Vec<_>>();
// which approaches the level of noise you expect from rust,
// but stylistically I much prefer having the type declaration near the definition.
But of course this example also highlights Rust's power. Often (usually) you don't need to do that, and you can instead use the iterator directly, saving all the intermediate allocations. With Rust, I can often write the kind of code I do in python, but without a single heap allocation. Also, it doesn't bind you to a single collection type that ships with the language; if you want to, you can easily use something like a vec with a short vec optimization instead.But it definitely does inherit Perl's mantle as executable line noise.
Instead of writing out a turbofish both times, I’d probably leave the first unannotated and put `::Vec<Vec<_>>` on the second one.