5

Stabilise inherent_ascii_escape (FCP in #77174) by clarfonthey · Pull Request #9...

 3 years ago
source link: https://github.com/rust-lang/rust/pull/93886
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Collaborator

rust-highfive commented 6 days ago

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@@ -804,7 +803,7 @@ impl u8 {

/// ```

#[must_use = "this returns the escaped byte as an iterator, \

without modifying the original"]

#[unstable(feature = "inherent_ascii_escape", issue = "77174")]

#[stable(feature = "inherent_ascii_escape", since = "1.60.0")]

#[inline]

pub fn escape_ascii(&self) -> ascii::EscapeDefault {

This doesn't really matter -- particularly with the inline annotation -- but it feels like this should take u8 rather than &u8.

I guess we've already FCP'd with this signature and changing the signature might cause some use sites to break at this point, but seems unfortunate.

Copy link

Contributor

Author

@clarfonthey clarfonthey 5 days ago

This is an unfortunate side-effect of all the AsciiExt methods being moved to inherent versions while retaining the references. :(

Sadly, it's the most consistent with the other ASCII methods.

The tracking issue FCP is actually for fn escape_ascii(self) -> ascii::EscapeDefault, and it looks like the original PR introducing these had a similar comment to mine requesting we use self (#73111 (comment))

I think we should update this to be self rather than &self prior to stabilizing it; consistency with other methods isn't really important.

Copy link

Contributor

Author

@clarfonthey clarfonthey 5 days ago

Oh wow, that's 100% my bad. I'll make another PR to merge that change then rebase this on that. Not sure whether you'd wanna do a second FCP or just merge it.

Copy link

Contributor

Author

@clarfonthey clarfonthey 5 days ago

(rebase done, pending tests passing)

I don't think we need a second FCP, I'm happy to r+ this PR directly.

clarfonthey reacted with heart emoji

Copy link

Contributor

Author

@clarfonthey clarfonthey 5 days ago

Sounds good to me! Figured I'd be safe just in case you wanted to wait a bit between the change and stabilisation.

FWIW, self vs &self matters quite a bit when the method in question is passed as a function pointer, eg. to an iterator combinator. Having to eta expand Foo::bar to |x| x.bar() is a papercut, particularly if it's inconsistent.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK