-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Bringing OsStr
and CStr
up to par with str
#1876
Comments
But you can return a |
I think I could probably draft up an RFC for that. I'd like to bring these up to par with I'd prefer feature parity because the entire point of these classes is to avoid converting to I'd recommend a |
@clarcharr The libs team has long wanted to do this, but have lacked the bandwidth. See #1309 for some starting points, and feel free to ping me if you'd like to discuss further. You could even sit in on a libs team meeting to sketch out ideas, if you like. |
Currently,
OsStr
provides a very rudimentarylen
function, which is used to determine capacity requirements forOsString
. I feel like this is grounds enough to allow slicing over these strings.The main use case for this would be storing multiple strings in the same
OsStr
buffer, then slicing them out based upon their lengths. This is particularly useful if you have a struct which requires multipleOsStr
s but don't want to allocate a new box for each one, and know the lengths of all of them.This is particularly useful because while
CStr
andstr
both have ways of accessing the bytes that make up the string,OsStr
doesn't.Obviously, slicing wouldn't make sense on
CStr
, because you can't just inject nuls into the middle of the string. However, it could also benefit from similar capacity-based functions onOsString
alongside some kind ofpush
method. Right now, you have to convert the string to a vec, mess with the string, then re-convert it into aCString
to do any of this stuff.While these types are not as widely used as
String
, it'd be nice if they were more consistent withString
's API.The text was updated successfully, but these errors were encountered: