-
Notifications
You must be signed in to change notification settings - Fork 19
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
OsString::truncate #486
Comments
This would be useful indeed. I'd recommend including a |
|
We discussed this in the libs-api meeting and are happy to accept this! When writing the documentation, we should be careful to properly specify what the boundary is and that it is platform-specific. |
By way of examples, the documentation could mention that you can expect to always get a valid truncate boundary by:
|
Shouldn't OsStr::slice_encoded_bytes be amended to also note these are valid ways of finding a boundary? Also, I'll start work on implementing this right away. |
Proposal
Problem statement
Truncating an
OsString
without using unsafe code.Motivating examples or use cases
re-using a
PathBuf
by repeatedly truncating it to its original length.Solution sketch
Modeled after
String::truncate
andOsStr::slice_encoded_bytes
.Alternatives
std::mem::swap
andfrom_encoded_bytes_unchecked
.PathBuf::pop
in a loop, but this is less effecient, especially for long paths.Links and related work
What happens now?
This issue contains an API change proposal (or ACP) and is part of the libs-api team feature lifecycle. Once this issue is filed, the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.
Possible responses
The libs team may respond in various different ways. First, the team will consider the problem (this doesn't require any concrete solution or alternatives to have been proposed):
Second, if there's a concrete solution:
The text was updated successfully, but these errors were encountered: