Conversation
|
(rust-highfive has picked a reviewer for you, use r? to override) |
a3c669a to
289e40c
Compare
I would expect this to be a re-export, i.e., r? rust-lang/libs-api as an API change though, since I believe EscapeAscii is new here. |
I'm fine doing that, I mostly wasn't sure how that would interact with stability since I thought in some cases that could accidentally stabilise the original. But this is mostly just vague memories of a really long time ago so I don't know what the best solution is today. |
289e40c to
e1de24b
Compare
dtolnay
left a comment
There was a problem hiding this comment.
I'm not sure about core::num::EscapeAscii. Contrasted with the existing stable core::slice::EscapeAscii which escapes an ASCII slice, I don't find it clear to say that this one "escapes an ASCII number". The standard library's use of 'number' refers to arithmetic objects, not atoms of text. For atoms of text it tends to call them 'byte'. For example consider the difference between str.as_bytes() vs str.as_numbers().
Mentioning @rust-lang/libs-api in case someone has a preference for this or any of the alternatives listed in #77174 (comment): core::char, core::str, or one I'll add: core::u8::EscapeAscii, or that we should keep a core::ascii module, or add core::byte or core::bytes, or …
|
I agree that I actually kind of like the idea of a Since the end result is unstable either way, my main intent was to just lay most of the groundwork that would be required for renaming this type, without actually committing to it. However, if we do want to move it to |
|
|
dtolnay
left a comment
There was a problem hiding this comment.
We discussed this PR in today's T-libs-api meeting and our impression was that we would prefer to keep core::ascii for now. core::num was not favorable to anyone, and there was a vague sense that core::byte or core::bytes would be valuable (to avoid overloading core::u8 to mean both the "number" u8 and the "byte" u8), but not if this iterator type is the only thing in there. We would be open to moving into core::byte in the future if other things arise that sensibly belong in that module. core::str was discussed but this iterator type has nothing to do with the type str, core::char was discussed but this has almost nothing to do with the type char, and core::fmt was discussed but this type has nothing to do with the Formatter API, so overall none of those were seen as sufficiently compelling over keeping core::ascii.
I'll close this PR, but we would still be interested in just the documentation parts of this PR, so I would be happy to accept a new PR containing just those. In particular treating https://doc.rust-lang.org/1.60.0/core/primitive.u8.html#method.escape_ascii as the place where the behavior is described in detail, and having https://doc.rust-lang.org/1.60.0/core/ascii/fn.escape_default.html link to it, instead of vice versa; and having https://doc.rust-lang.org/1.60.0/core/ascii/struct.EscapeDefault.html indicate that it is constructed by the inherent method, not the function.
Thanks!
This is required for #93887. The change does three things, namely:
escape_defaultmethod into the inherentescape_asciimethod, since the inherent version is preferred. This mirrors what was done for the deprecatedAsciiExttrait, which also just references the inherent replacements.EscapeDefaultinto thecore::nummodule, where it's exported ascore::num::EscapeAsciiinstead. To do this, I mostly just copied thecore::asciimodule intocore::num::asciiand renamed the type, although I also edited theDebugimplementation for good measure.EscapeDefaulttype is replaced with a type alias. Regardless of what name the new version is stabilised as, this shouldn't actually affect compatibility. (todo: verify this?)Note that the code appears slightly different in the moved module since the original was never
rustfmted. Somehow, it even ended with areturn value;before the change, showing its age.