Logo

Programming-Idioms

History of Idiom 118 > diff from v58 to v59

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

Version 58

2021-01-07, 11:28:19

Version 59

2021-03-31, 20:16:26

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();
Doc URL
https://doc.rust-lang.org/std/collections/struct.HashSet.html
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=249ed04ef4a59c1ad632f7d728c6445e
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=249ed04ef4a59c1ad632f7d728c6445e