-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Tracking Issue for utf8_chunks
#99543
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
…lacrum Expose `Utf8Lossy` as `Utf8Chunks` This PR changes the feature for `Utf8Lossy` from `str_internals` to `utf8_lossy` and improves the API. This is done to eventually expose the API as stable. Proposal: rust-lang/libs-team#54 Tracking Issue: rust-lang#99543
I'd be interested in using this to implement Display and Debug for
Here is what it looks like using Utf8Chunks as currently exists in nightly: Are there other known use cases so far that we could look at before an FCP? One thing I am interested in is how the current Utf8Chunks API compares with this alternative one, not based on Iterator, with just 1 type: pub struct Utf8Chunks<'a>;
impl<'a> Utf8Chunks<'a> {
pub fn next_valid(&mut self) -> &'a str;
pub fn next_invalid(&mut self) -> &'a [u8];
} |
@dtolnay I am currently waiting on this ACP for stabilization.
I am aware of the following use cases.
I was originally going to use this feature in
My concern is that the alternate API is easier to misuse (e.g., calling |
@dylni generally, you don't need an ACP for this to stabilise (unless the team explicitly asked for it which I don't think happened in this case). |
@Dylan-DPC Right, but the problem is that the ACP would change the API. Stabilizing at this point would prevent the API change from landing. |
@rust-lang/libs-api: I propose stabilizing I recently wanted this API for C++ string Debug impls in cxx as described in #99543 (comment), and also in libproc_macro for synthesizing C-string literals in #123769. |
Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Note that this same API, under the same name, is also in
With that said, does this mean we also have an |
Yeah there would be 2 "itertools situations": Code that calls
|
Thanks @dtolnay! I filed an issue on I think it would be nice to have |
Do you happen to know any real-world usages of I would prefer not to blindly copy |
I don't have a specific example to point to unfortunately. But it's similar in concept at least to |
I don't remember exactly what I needed that function for, but I'm sure I sent that PR because I actually needed it. I can't find any uses of it in any of the code I currently have checked out, but it looks like at that time I was working on two relevant (never finished) projects where I might have needed this: 1. a terminal emulator, and 2. some embedded project with serial communication in chunks. There is some separate discussion on use cases in this issue: BurntSushi/bstr#42 |
Stabilize `Utf8Chunks` Pending FCP in rust-lang#99543. This PR includes the proposed modification in rust-lang/libs-team#190 as agreed in rust-lang#99543 (comment).
Unless |
GitHub search for "chunk.incomplete()" (guessing a likely variable name) shows 0 hits. GitHub search for ".incomplete()" shows 123 hits, of which I looked through all of them and 0 are related to utf8 chunks. In #123909, crater uncovered 0 uses of As such, I recommend that we do not import bstr's Crater showed a single occurrence of the second type of expected break in #99543 (comment). The affected crate is actively developed (within the past 5 days) and is not depended on by any other crate on crates.io. This breakage is allowed by the standard library's API evolution policy (https://rust-lang.github.io/rfcs/1105-api-evolution.html#minor-change-adding-any-inherent-items). I recommend that we move forward with #123909 as written (when the FCP completes in 2 days, of course). |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
Stabilize `Utf8Chunks` Pending FCP in rust-lang#99543. This PR includes the proposed modification in rust-lang/libs-team#190 as agreed in rust-lang#99543 (comment).
Stabilize `Utf8Chunks` Pending FCP in rust-lang/rust#99543. This PR includes the proposed modification in rust-lang/libs-team#190 as agreed in rust-lang/rust#99543 (comment).
Stabilize `Utf8Chunks` Pending FCP in rust-lang/rust#99543. This PR includes the proposed modification in rust-lang/libs-team#190 as agreed in rust-lang/rust#99543 (comment).
Feature gate:
#![feature(utf8_chunks)]
This is a tracking issue for an improved API for
str::from_utf8
.Public API
Steps / History
Utf8LossyChunksIter
libs-team#54Utf8Lossy
asUtf8Chunks
#99544Unresolved Questions
Utf8Chunks::new
or<[u8]>::utf8_chunks
?Utf8Chunks::debug
or a similar method be exposed?Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: