Comment

Comment by mrkeen

  data.iter()
      .filter(|w| w.alive)
      .map(|w| w.id)
      .collect()

  collect(map(filter(iter(data), |w| w.alive), |w| w.id))
The second approach is open for extension - it allows you to write new functions on old datatypes.

> Quick challenge for the curious Rustacean, can you explain why we cannot rewrite the above code like this, even if we import all of the symbols?

Probably for lack of

> weird operators like <$>, <*>, $, or >>=

parent mrkeen 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton