How to create HashSet in Rust

1 Answer

0 votes
use std::collections::HashSet;

fn main() {
    let mut hs = HashSet::new();

    hs.insert("Rust");
    hs.insert("C");
    hs.insert("C");
    hs.insert("C++");
    hs.insert("C");

    println!("{:?}", hs);
}


 
 
/*
run:
 
{"C++", "C", "Rust"}
 
*/

 



answered Oct 29, 2022 by avibootz
...