Logo

Programming-Idioms

History of Idiom 12 > diff from v56 to v57

Edit summary for version 57 by programming-idioms.org:
[Rust] +DocURL

Version 56

2017-05-21, 22:07:17

Version 57

2017-05-21, 22:11:30

Idiom #12 Check if list contains a value

Check if list contains a value x.
list is an iterable finite container.

Illustration

Idiom #12 Check if list contains a value

Check if list contains a value x.
list is an iterable finite container.

Illustration
Extra Keywords
array vector
Extra Keywords
array vector
Code
(&list).into_iter().any(|v| v == &x)
Code
(&list).into_iter().any(|v| v == &x)
Comments bubble
This is the the truly general version, but it isn't the most idiomatic.
Comments bubble
This is the the truly general version, but it isn't the most idiomatic.
Doc URL
https://doc.rust-lang.org/std/iter/trait.IntoIterator.html#tymethod.into_iter
Demo URL
https://is.gd/hZWiKW
Demo URL
https://is.gd/hZWiKW