Logo

Programming-Idioms

History of Idiom 57 > diff from v10 to v11

Edit summary for version 11 by :

Version 10

2015-08-01, 17:02:25

Version 11

2015-08-18, 13:48:07

Idiom #57 Filter list

Create list y containing items from list x satisfying predicate p. Respect original ordering. Don't modify x in-place.

Idiom #57 Filter list

Create list y containing items from list x satisfying predicate p. Respect original ordering. Don't modify x in-place.

Code
let y: Vec<_> = x.iter().filter(p).collect();
Comments bubble
Iterators are very powerful.

This collects into a vector (other collections are possible).
Demo URL
http://is.gd/sY2SUv