-
Notifications
You must be signed in to change notification settings - Fork 20
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
Expose Utf8LossyChunksIter
#54
Comments
The |
Regardless of that minor detail, I'm in favor of working towards exposing this as a public API! |
Great! I agree that basing the API off bstr would be sensible, so I have updated the issue. The changes were actually surprisingly close already, but providing methods instead of fields will be better for future compatibility. I'm leaving out the Also, it might be worth discussing if the constructor should be |
@m-ou-se Is this proposal ready for a PR? It still has the "initial-comment-period" label, so I'm not sure if it's been agreed that this should be added. |
@dylni Sorry! We don't have this processs automated yet. Yes, feel free to go ahead and open a tracking issue for this new unstable feature and send a PR for its implementation. |
Thanks! Tracking issue: rust-lang/rust#99543 |
…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
This has been merged: rust-lang/rust#99544 |
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: #99543
Proposal
Problem statement
When
Utf8Error::valid_up_to
andUtf8Error::error_len
are used, their results will almost always be used to get substrings of the original string. However, sinceUtf8Error
does not have a reference to the original string, it cannot have methods to return the substrings.Utf8LossyChunksIter
is also much easier to use.Motivation, use-cases
This is useful when creating a custom byte string formatter. UTF-8 portions are usually output using the
Display
implementation forstr
orstr::escape_debug
, but invalid portions might require custom formatting.Example
Code using
str::from_utf8
(requiresunsafe
):Code using the new API:
Solution sketches
Make the following changes, and change the feature for these structs from
str_internals
toutf8_chunks
.Utf8Lossy
.Utf8LossyChunksIter
toUtf8Chunks
.Utf8LossyChunk
toUtf8Chunk
.Utf8LossyChunk::broken
toinvalid
.Utf8Chunks
into getter methods (i.e.,valid
andinvalid
).Links and related work
What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.
The text was updated successfully, but these errors were encountered: