std-method
HashSet::is_subset
Check whether every element in self belongs to other. Equality counts as a subset, as does the empty set. Expected stdout (not executed): true false Common mistake: Reversing the operands when checking required permissions against granted permissions.
Formal Syntax & Structure
rust syntaxrust
pub fn is_subset(&self, other: &HashSet<T, S>) -> boolWorking Example
Example Snippetrust
fn main() { use std::collections::HashSet; let required = HashSet::from(["read"]); let granted = HashSet::from(["read", "write"]); println!("{} {}", required.is_subset(&granted), granted.is_subset(&required));}