`BTreeSet` composite key

⚓ Rust    📅 2025-06-19    👤 surdeus    👁️ 4      

surdeus

Warning

This post was published 55 days ago. The information described in this article may have changed.

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: `BTreeSet` composite key

When I have BTreeSet<String>, I can check that it contains some string via let s: &str = ...; set.contains(s) - no clone involved. But if I have BTreeSet<(i32, String)>, I cant just set.contains((number, s)), I need set.contains(&(number, s.to_string()). Is there some way to avoid needless allocations and fulfill the use case?

As I see it, Borrow trait as a solution for maps is poor, as it is extremely limited.

5 posts - 3 participants

Read full topic

🏷️ rust_feed