std: make OsString::truncate a no-op when len > current_len#152998
Open
xtqqczze wants to merge 1 commit intorust-lang:mainfrom
Open
std: make OsString::truncate a no-op when len > current_len#152998xtqqczze wants to merge 1 commit intorust-lang:mainfrom
OsString::truncate a no-op when len > current_len#152998xtqqczze wants to merge 1 commit intorust-lang:mainfrom
Conversation
Collaborator
|
r? @jhpratt rustbot has assigned @jhpratt. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
9be1130 to
3c790ce
Compare
This comment has been minimized.
This comment has been minimized.
3c790ce to
14f592a
Compare
This comment has been minimized.
This comment has been minimized.
14f592a to
768010a
Compare
asder8215
reviewed
Feb 24, 2026
768010a to
294a7e2
Compare
OsString::truncate a no-op when len >= current_lenOsString::truncate a no-op when len > current_len
Align `OsString::truncate` (and the underlying WTF-8 implementation) with `String::truncate` by making it a no-op when `len > self.len()`. Previously, `OsString::truncate` would panic if `len > self.len()`, while `String::truncate` treats such cases as a no-op.
294a7e2 to
3ecd18c
Compare
Member
|
This seems reasonable, but has it been discussed anywhere? |
Contributor
|
I don't think it was discussed anywhere to my knowledge, maybe in the original implementation PR? Parity seems like a good idea, but should we ask t-libs-api for confirmation? |
Member
|
cc @rust-lang/libs-api; given that it's unstable I'm not sure what procedure is here. |
Contributor
Yea, I would defer this to lib-api to make the call. |
Amanieu
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Align
OsString::truncate(and the underlying WTF-8 implementation) withString::truncateby making it a no-op whenlen > self.len().Previously,
OsString::truncatewould panic iflen > self.len(), whileString::truncatetreats such cases as a no-op.Tracking (
os_string_truncate): #133262See also: #32977
cc: @alexcrichton, @lolbinarycat