-
Notifications
You must be signed in to change notification settings - Fork 285
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
Feature: Consider providing StrBytes
interface
#373
Comments
Does something like this work? https://docs.rs/string/0.2.1/string/ |
Yes. 👍 |
The |
The |
This would act like the
Bytes
object but would guarantee that the contents are valid utf-8. It would not implementBuf
but would deref to&str
and have conversions to theString
type.There would be
TryFrom/TryInto
conversions fromBytes
toStrBytes
which would scan the string for validity but would not copy it. There would be zero-costFrom/Into
conversions fromStrBytes
toBytes
. There would be an unsafe zero-cost conversion method fromBytes
toStrBytes
for when the bytes are already known to be valid.It would be convenient (but not essential) if there was a way to general substring-returning operations on a
StrBytes
that themselves returned aStrBytes
.This would enable zero-copy string deserialization in the same way as for raw bytes.
The text was updated successfully, but these errors were encountered: