Warning
This post was published 55 days ago. The information described in this article may have changed.
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
🏷️ rust_feed