-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove Borrow<BStr> for String
impls (and similar) in a semver compatible release
#168
Comments
It is absolutely safe to do so, yes. Is it correct to do so? Maybe. It certainly appears to be the case that the current configuration is not correct though. I wonder what the right thing to do here is. I see a few different paths:
If we decide on path (1), then to be clear, it won't happen any time soon. I don't plan on putting out a |
3 is possible for sure. Something like this would match the Hash impl for str. impl core::hash::Hash for BStr {
fn hash<H: core::hash::Hasher>(&self, h: &mut H) {
h.write(self.as_bytes());
h.write_u8(0xff);
}
} Unfortunately this would still be different from the Hash impl for |
Yeah, indeed, we have |
@Xuanwo For you, I think the work-around is to define a newtype with the semantics you need. (And this is likely what The Real Solution would be anyway, since it seems like |
A newtype sounds correct within the current HashMap interface, but I'm afraid that how |
Another thought: can we declare However I agree that dropping it is technically a breaking change, so we can't be more careful on this... |
@XeCycle That is perhaps defensible given that it's incorrect and leads to incorrect results in practice. I think it's likely that's the route I'll go. We don't have crater for crates though, so it's hard to know the impact. One thing I can perhaps do is issue a release with a deprecation warning that it's going to be removed so that folks not following the issue tracker have a chance to act before the breakage is upon them. |
Borrow<BStr> for String
?Borrow<BStr> for String
impls (and similar) in a semver compatible release
It's quite hard to find use cases as described. I searched for Besides, there are 243 reverse dependencies listed at https://crates.io/crates/bstr/reverse_dependencies. I'm considering writing some scripts to patch |
If you want to do that, that would be most appreciated. Although regardless of the result of that, I'm likely to at least push this through a deprecation period to give folks time to migrate away from the broken API. |
Given the following code:
We expect it to pass, but failed. The root cause is: the hash for identical content differs between a String and bytes.
Considering
Borrow
's requirement:Is it safe to implement
Borrow<BStr> for String
?The text was updated successfully, but these errors were encountered: