std-method
HashSet::remove
Delete the matching element and report whether it was present. The removed value is not returned. Expected stdout (not executed): true false Common mistake: Expecting the result to contain the removed String; use take for that.
Formal Syntax & Structure
rust syntaxrust
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool where T: Borrow<Q>, Q: Hash + EqWorking Example
Example Snippetrust
fn main() { use std::collections::HashSet; let mut s = HashSet::from(["draft", "final"]); println!("{} {}", s.remove("draft"), s.remove("draft"));}