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.
You can do this with some dyn Trait tricks, but I think the coherence rules will require that you define your own key type instead of using a bare tuple.