Skip to content
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

Add char::code_point #83496

Closed
wants to merge 4 commits into from
Closed

Add char::code_point #83496

wants to merge 4 commits into from

Conversation

Aehmlo
Copy link

@Aehmlo Aehmlo commented Mar 25, 2021

In #79502, which introduced From<char> for u{64,128}, some desire for a dedicated code point method on char was expressed. This PR implements char::code_point (where the underscore comes from the fact that the documentation and Unicode both stylize it as two words, i.e., "code point" instead of "codepoint"). The method is simply implemented as self as u32.

This method is equivalent to conversion using `as`, but with a more
domain-specific name.
@rust-highfive
Copy link
Collaborator

r? @dtolnay

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 25, 2021
@rust-log-analyzer

This comment has been minimized.

@camelid camelid added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. A-Unicode Area: Unicode labels Mar 25, 2021
@Aehmlo
Copy link
Author

Aehmlo commented Mar 25, 2021

I see that CI failed due to a missing stability attribute. I admit to some confusion about how to handle this: does adding the attribute to library/core/src/char/methods.rs suffice, or do I also need to register the feature in compiler/rustc_feature?

@crlf0710
Copy link
Member

@Aehmlo For library functions the former will suffice.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

The example was previously based on the character "a," but was since
revised to use a more "interesting" character. When making this change,
I neglected to change the "magic number" in the doctest.

On the upside, I think the tests should pass now.
@Aehmlo
Copy link
Author

Aehmlo commented Mar 26, 2021

All right, I think this one should do it.

@joshtriplett
Copy link
Member

https://doc.rust-lang.org/core/str/fn.next_code_point.html serves as further naming precedent.

@joshtriplett
Copy link
Member

This should not be insta-stable. It should be marked as unstable, with a tracking issue and a feature gate.

Otherwise the method itself seems reasonable to me.

@joshtriplett joshtriplett added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 26, 2021
@JohnCSimon
Copy link
Member

ping from triage:
@Aehmlo - can you address the comments from joshtriplett?

@camelid
Copy link
Member

camelid commented Apr 12, 2021

Docs for the #[unstable] attribute: https://rustc-dev-guide.rust-lang.org/stability.html#unstable

@Aehmlo
Copy link
Author

Aehmlo commented Apr 15, 2021

Yes, I'll stick this behind a feature gate (and probably rebase) when I get a chance — hopefully this weekend. Thanks for the link to the docs!

@crlf0710
Copy link
Member

crlf0710 commented May 1, 2021

@Aehmlo any updates on this?

@crlf0710 crlf0710 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 1, 2021
@JohnCSimon JohnCSimon added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label May 17, 2021
@JohnCSimon
Copy link
Member

triage:
@Aehmlo I'm closing this as inactive, please feel free to reopen when you want to continue with this.
Thank you!

@JohnCSimon JohnCSimon closed this May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Unicode Area: Unicode S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants