There are hidden assumptions around Borrow that don’t appear to be included in any of the documentation that I can find. Most notably, HashMap’s use of Borrow requires that K and Q (where K: Borrow<Q>) hash the same; if they don’t, your HashMap will be mysteriously broken when you try indexing it by Q.
I’d suggest making Borrow an unsafe trait, but unsafe doesn’t mean blah blah mumble mumble memory safety mumble 😛
Anyway, we need some serious warnings on at least the Borrow documentation. Something including things like “if you are implementing Borrow and both Self and Borrowed implement Hash, they must produce the same result, for HashMap’s sake.”
There are hidden assumptions around
Borrowthat don’t appear to be included in any of the documentation that I can find. Most notably,HashMap’s use ofBorrowrequires thatKandQ(where K: Borrow<Q>) hash the same; if they don’t, yourHashMapwill be mysteriously broken when you try indexing it byQ.I’d suggest making
Borrowan unsafe trait, but unsafe doesn’t mean blah blah mumble mumble memory safety mumble 😛Anyway, we need some serious warnings on at least the
Borrowdocumentation. Something including things like “if you are implementingBorrowand bothSelfandBorrowedimplementHash, they must produce the same result, for HashMap’s sake.”