Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Rust's Poor Composability. Parent comment
`let res: Result<Vec<_>, _> = iterator.iter().map(|x| x.foo()).collect();`
Left to right reading this statement is "iterate over the values and map it to the output of foo for each value. Then collect that map into a vector."
His other example
``` for (i, x) in something.iter_mut().filter(|| {...}).enumerate() { x = (x) * i } ```
can also be read from left to right as "iterate over something, then filter and enumerate the values"
It's much more explanatory than top down structures with 10 lines to explain the same thing.
There are no comments on this comment yet.
`let res: Result<Vec<_>, _> = iterator.iter().map(|x| x.foo()).collect();`
Left to right reading this statement is "iterate over the values and map it to the output of foo for each value. Then collect that map into a vector."
His other example
``` for (i, x) in something.iter_mut().filter(|| {...}).enumerate() { x = (x) * i } ```
can also be read from left to right as "iterate over something, then filter and enumerate the values"
It's much more explanatory than top down structures with 10 lines to explain the same thing.