Uh oh!
There was an error while loading. Please reload this page.
std/OsString: Add detailed comment on args meaning - #95139
Conversation
Signed-off-by: Xuanwo <github@xuanwo.io>
rust-highfive
commented
Mar 20, 2022
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
Also, ping @dtolnay & @TennyZhuang for a look, thanks. |
Xuanwo
commented
Mar 20, 2022
r? @dtolnay |
Hmm, I'm not sure I understand. A The only difference would be where an |
dtolnay
commented
Mar 27, 2022
@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. |
dtolnay
commented
Mar 28, 2022
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. |
Xuanwo
commented
Mar 28, 2022
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`, closesrust-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`, closesrust-lang/rust#91789 This PR will also replace the previous PR: rust-lang/rust#95139
Signed-off-by: Xuanwo github@xuanwo.io
Part of #91789
Address the concern: