Skip to content
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

Index trait not implemented for BString #190

Open
eddybruel opened this issue Sep 22, 2024 · 4 comments
Open

Index trait not implemented for BString #190

eddybruel opened this issue Sep 22, 2024 · 4 comments
Labels
breaking change Requires a semver incompatible release.

Comments

@eddybruel
Copy link

When trying to use bstr in my own project, I noticed that slicing a BString yields a &[u8], while slicing a BStr yields a &BStr (which is what I'd expect).

Upon closer inspection, it looks like the Index trait is implemented for BStr, but not for BString, which is not what I'd expect. I'm not sure if this was a deliberate design decision or just an oversight, so I just wanted to bring this to your attention.

@BurntSushi
Copy link
Owner

Yup. This looks like an oversight. Slicing a BString I guess should probably yield a BStr. This can't be fixed without a breaking change, which I don't plan on releasing any time soon, if ever.

You can probably work around this by derefing a BString to BStr and then slicing.

@eddybruel
Copy link
Author

Thanks for confirming. I can simply work around it by wrapping the resulting slice in a call to BStr::new(..). Bit of a wart, but nothing too bad.

Appreciate the quick reply!

@eddybruel
Copy link
Author

Closing this since it cannot be fixed without a breaking change, which doesn't seem worth it.

@BurntSushi
Copy link
Owner

I'll keep it open in the event that a bstr 2.0 ever occurs.

@BurntSushi BurntSushi reopened this Sep 22, 2024
@BurntSushi BurntSushi added the breaking change Requires a semver incompatible release. label Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Requires a semver incompatible release.
Projects
None yet
Development

No branches or pull requests

2 participants