std-type
HashSet<T> — unique membership
Store at most one element from each equality class. For insertion and lookup, elements need compatible Eq and Hash behavior. Use it when membership and uniqueness matter more than sequence order. Expected stdout (not executed): 2 true Common mistake: Expecting a set to preserve duplicate values or insertion order.
Formal Syntax & Structure
rust syntaxrust
HashSet<T, S = RandomState>Working Example
Example Snippetrust
fn main() { use std::collections::HashSet; let tags = HashSet::from(["rust", "web", "rust"]); println!("{} {}", tags.len(), tags.contains("web"));}