-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Re-export core::ascii::EscapeDefault as core::num::EscapeAscii #95227
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
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_default
method into the inherentescape_ascii
method, since the inherent version is preferred. This mirrors what was done for the deprecatedAsciiExt
trait, which also just references the inherent replacements.EscapeDefault
into thecore::num
module, where it's exported ascore::num::EscapeAscii
instead. To do this, I mostly just copied thecore::ascii
module intocore::num::ascii
and renamed the type, although I also edited theDebug
implementation for good measure.EscapeDefault
type 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
rustfmt
ed. Somehow, it even ended with areturn value;
before the change, showing its age.