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

core::str::{chars_uppercase,chars_lowercase} iterators #98490

Closed
wants to merge 1 commit into from

Conversation

markokr
Copy link

@markokr markokr commented Jun 25, 2022

They are based on new UnicodeConverter + UnicodeIterator
internal API that supports context-sensitivity and char expansion.

API change proposal: rust-lang/libs-team#58

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Jun 25, 2022
@rust-highfive
Copy link
Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 25, 2022
@thomcc
Copy link
Member

thomcc commented Jun 25, 2022

This is a new API, so please file an API change proposal (see the links in the bot post). That said, I'm very much in favor of this, and a quick skim (will need more thorough review once it gets API sign off) looks fine.

@rustbot label +T-libs-api -T-libs

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 25, 2022
@rust-log-analyzer

This comment has been minimized.

@markokr
Copy link
Author

markokr commented Jun 25, 2022

Thanks for quick feedback!

Created API proposal here: rust-lang/libs-team#58

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

They are based on new UnicodeConverter + UnicodeIterator
internal API that supports context-sensitivity and char expansion.
@thomcc thomcc added S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 22, 2022
Copy link
Member

@thomcc thomcc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the implementation here is more generic than it needs to be, and more complex as a result. You should not do this via a trait IMO -- The way you've decoupled it here also requires more bounds-checks which shouldn't be needed, and avoiding them in this interface would require otherwise-unnecessary unsafe code (to be clear: I'm not asking for you to add unsafe to this).

I think chars_lowercase should be a bit more like what you'd get by manually performing s.chars().flat_map(|c| c.to_lowercase()). Uppercase is the complex one, but should be handled directly, closer to the implementation in liballoc.

Let me know if you need an example of what I mean.

///
/// Default implementation is pass-through, no conversion is done,
/// with `is_simple = is_ascii`.
trait UnicodeConverter {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this shouldn't use a trait. I think this ends up complicating things quite a bit and makes the implementation overly generic.

// data source
iter: CharIndices<'a>,
// buffer for .next()
fwd: [Option<char>; 2],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: forward/backward instead of fwd/bwd.

@@ -144,6 +144,7 @@
#![feature(unicode_internals)]
#![feature(unsize)]
#![feature(std_internals)]
#![feature(unicode_converter)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature name is too generic, perhaps something more like #![feature(str_chars_casemapped)]?

@bors
Copy link
Contributor

bors commented Aug 17, 2022

☔ The latest upstream changes (presumably #100644) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 17, 2022
@JohnCSimon
Copy link
Member

Ping from triage:
@markokr what is the status of this PR?

@JohnCSimon
Copy link
Member

@markokr
Ping from triage: I'm closing this due to inactivity, Please reopen when you are ready to continue with this.
Note: if you do please open the PR BEFORE you push to it, else you won't be able to reopen - this is a quirk of github.
Thanks for your contribution.

@rustbot label: +S-inactive

@JohnCSimon JohnCSimon closed this Jan 1, 2023
@rustbot rustbot added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Jan 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. 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.

7 participants