std-method
BTreeSet::contains
Check membership using a borrowed form with matching order. A String set supports str lookups without allocating an owned query. Expected stdout (not executed): true false Common mistake: Searching with an unrelated ordering rule such as case-insensitive comparison.
Formal Syntax & Structure
rust syntaxrust
fn contains<Q>(&self, value: &Q) -> bool where T: Borrow<Q> + Ord, Q: Ord + ?SizedWorking Example
Example Snippetrust
fn main() { use std::collections::BTreeSet; let tags = BTreeSet::from([String::from("rust"), String::from("linux")]); println!("{} {}", tags.contains("rust"), tags.contains("go"));}