-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
std/OsString: Add detailed comment on args meaning #95139
Conversation
Signed-off-by: Xuanwo <[email protected]>
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
Also, ping @dtolnay & @TennyZhuang for a look, thanks. |
r? @dtolnay |
Hmm, I'm not sure I understand. A The only difference would be where an |
@ChrisDenton the internal representation and therefore byte size are the same. And str's length/capacity are defined as bytes. But nothing says that OsStr capacity is measured in bytes. It could be measured in nibbles for example, and that would be a correct standard library implementation conforming to the currently documented guarantees. |
Hm, are the docs intentionally vague on this or is it an unintended omission? str len and OsStr len returning the length in different units would be very surprising to me on any platform. |
I think it's not vague and it's not an unintended omission. This part of the OsString docs discusses it:
This is saying that the "storage size" of an OS string (which is the size that
And
At a previous job I worked on the compiler for an accelerator that used 16-bit bytes but the application processor attached to it had 8-bit bytes, so it's not strange to me that data for different purposes would be measured differently. On that system the accelerator could store an OS string in half the number of bytes that it would take to store a native string, because the OS's bytes are all small. If you took a native string and cast it to an OS string, keeping the same memory representation, you'd have an OS string that was twice as long as your original native string. |
This PR has been replaced by #95392, I'm going to close it now. Please take a look at the new PR instead. Thank @ChrisDenton & @dtolnay for reviewing! 💘 |
…olnay std: Stabilize feature try_reserve_2 This PR intends to stabilize feature `try_reserve_2`, closes rust-lang#91789 This PR will also replace the previous PR: rust-lang#95139
std: Stabilize feature try_reserve_2 This PR intends to stabilize feature `try_reserve_2`, closes rust-lang/rust#91789 This PR will also replace the previous PR: rust-lang/rust#95139
Signed-off-by: Xuanwo [email protected]
Part of #91789
Address the concern: