Logo

Programming-Idioms

History of Idiom 118 > diff from v47 to v48

Edit summary for version 48 by programming-idioms.org:
[Rust] +DemoURL

Version 47

2020-07-15, 16:41:47

Version 48

2020-07-18, 21:48:23

Idiom #118 List to set

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

Idiom #118 List to set

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

Variables
y,x
Variables
y,x
Imports
use std::collections::HashSet;
Imports
use std::collections::HashSet;
Code
let y: HashSet<_> = x.into_iter().collect();
Code
let y: HashSet<_> = x.into_iter().collect();
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=249ed04ef4a59c1ad632f7d728c6445e