Logo

Programming-Idioms

History of Idiom 118 > diff from v21 to v22

Edit summary for version 22 by TheVTM:
New Rust implementation by user [TheVTM]

Version 21

2016-11-30, 21:02:39

Version 22

2017-04-27, 09:51:33

Idiom #118 List to set

Create set y from list x.
x may contain duplicates. y is unordered and has no repeated values.

Illustration

Idiom #118 List to set

Create set y from list x.
x may contain duplicates. y is unordered and has no repeated values.

Illustration
Imports
use std::collections::HashSet;
Code
let y = x.iter().cloned().collect::<HashSet<_>>();
Demo URL
https://is.gd/0HSls9