You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To be clear: Almost the entire reason for Borrow to exist is to have "AsRef where Hash/Eq/Ord are expected to hold". (the rest of the reason is differing blanket impls in a world without specialization)
(not clear on what @SimonSapin meant with "may not be desirable")
Yes this was switched to Borrow from AsRef as @bluss pointed out due to coherence issues. Whether or not this is desirable we cannot switch to AsRef today, so I'm going to close this as working as intended.
The whole point of this library is to make Atom::eq fast. While we’re at it, we make Atom::hash fast in the same way. (That is, we only compare/hash the u64 value, not the str’s bytes.) The rest of the library ensures that *atom_1 == *atom_2 if and only if atom_1.magic == atom_2.magic.
To make make Atom::hash fast, we make it not consistent with str::hash. Therefore, Atom should not implement Borrow<str>.
SliceConcatExt however does not rely on hashing. Being able to use it on atoms would be nice.
Activity
frewsxcv commentedon Jul 5, 2015
A couple RFCs related to SliceConcatExt (for the sake of crosslinking):
bluss commentedon Jul 5, 2015
See discussion on #25162 why it was changed to Borrow
steveklabnik commentedon Jul 6, 2015
Yes, @aturon @alexcrichton , is this actually intended? Seems so
steveklabnik commentedon Jul 6, 2015
/cc @rust-lang/libs
Gankra commentedon Jul 6, 2015
To be clear: Almost the entire reason for Borrow to exist is to have "AsRef where Hash/Eq/Ord are expected to hold". (the rest of the reason is differing blanket impls in a world without specialization)
(not clear on what @SimonSapin meant with "may not be desirable")
alexcrichton commentedon Jul 6, 2015
Yes this was switched to
Borrow
fromAsRef
as @bluss pointed out due to coherence issues. Whether or not this is desirable we cannot switch toAsRef
today, so I'm going to close this as working as intended.SimonSapin commentedon Jul 6, 2015
In string-cache we have:
The whole point of this library is to make
Atom::eq
fast. While we’re at it, we makeAtom::hash
fast in the same way. (That is, we only compare/hash theu64
value, not thestr
’s bytes.) The rest of the library ensures that*atom_1 == *atom_2
if and only ifatom_1.magic == atom_2.magic
.To make make
Atom::hash
fast, we make it not consistent withstr::hash
. Therefore,Atom
should not implementBorrow<str>
.SliceConcatExt
however does not rely on hashing. Being able to use it on atoms would be nice.