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

Delete Utf8Lossy::from_str #91697

Merged
merged 1 commit into from
Dec 11, 2021
Merged

Delete Utf8Lossy::from_str #91697

merged 1 commit into from
Dec 11, 2021

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Dec 9, 2021

This whole type is marked as being for str internals only, but this constructor is never used by str internals. If you had a &str already and wanted to lossy display it or iterate its lossy utf8 chunks, you would simply not use Utf8Lossy because the whole &str is known to be one contiguous valid utf8 chunk.

If code really does need to obtain a value of type &Utf8Lossy somewhere, and has only a &str, Utf8Lossy::from_bytes(s.as_bytes()) remains available. As currently implemented, there is no performance penalty relative to from_str i.e. the Utf8Lossy does not "remember" that it was constructed using from_str to bypass later utf8 decoding.

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(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 Dec 9, 2021
@apiraino apiraino added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Dec 9, 2021
@Mark-Simulacrum
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 9, 2021

📌 Commit 4b0a9c9 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 9, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 9, 2021
…crum

Delete Utf8Lossy::from_str

This whole type is marked as being for str internals only, but this constructor is never used by str internals. If you had a &str already and wanted to lossy display it or iterate its lossy utf8 chunks, you would simply not use Utf8Lossy because the whole &str is known to be one contiguous valid utf8 chunk.

If code really does need to obtain a value of type &Utf8Lossy somewhere, and has only a &str, `Utf8Lossy::from_bytes(s.as_bytes())` remains available. As currently implemented, there is no performance penalty relative to `from_str` i.e. the Utf8Lossy does not "remember" that it was constructed using `from_str` to bypass later utf8 decoding.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 10, 2021
…crum

Delete Utf8Lossy::from_str

This whole type is marked as being for str internals only, but this constructor is never used by str internals. If you had a &str already and wanted to lossy display it or iterate its lossy utf8 chunks, you would simply not use Utf8Lossy because the whole &str is known to be one contiguous valid utf8 chunk.

If code really does need to obtain a value of type &Utf8Lossy somewhere, and has only a &str, `Utf8Lossy::from_bytes(s.as_bytes())` remains available. As currently implemented, there is no performance penalty relative to `from_str` i.e. the Utf8Lossy does not "remember" that it was constructed using `from_str` to bypass later utf8 decoding.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 10, 2021
…crum

Delete Utf8Lossy::from_str

This whole type is marked as being for str internals only, but this constructor is never used by str internals. If you had a &str already and wanted to lossy display it or iterate its lossy utf8 chunks, you would simply not use Utf8Lossy because the whole &str is known to be one contiguous valid utf8 chunk.

If code really does need to obtain a value of type &Utf8Lossy somewhere, and has only a &str, `Utf8Lossy::from_bytes(s.as_bytes())` remains available. As currently implemented, there is no performance penalty relative to `from_str` i.e. the Utf8Lossy does not "remember" that it was constructed using `from_str` to bypass later utf8 decoding.
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 11, 2021
…askrgr

Rollup of 11 pull requests

Successful merges:

 - rust-lang#91668 (Remove the match on `ErrorKind::Other`)
 - rust-lang#91678 (Add tests fixed by rust-lang#90023)
 - rust-lang#91679 (Move core/stream/stream/mod.rs to core/stream/stream.rs)
 - rust-lang#91681 (fix typo in `intrinsics::raw_eq` docs)
 - rust-lang#91686 (Fix `Vec::reserve_exact` documentation)
 - rust-lang#91697 (Delete Utf8Lossy::from_str)
 - rust-lang#91706 (Add unstable book entries for parts of asm that are not being stabilized)
 - rust-lang#91709 (Replace iterator-based set construction by *Set::From<[T; N]>)
 - rust-lang#91716 (Improve x.py logging and defaults a bit more)
 - rust-lang#91747 (Add pierwill to .mailmap)
 - rust-lang#91755 (Fix since attribute for const_linked_list_new feature)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2784051 into rust-lang:master Dec 11, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 11, 2021
@dtolnay dtolnay deleted the lossyfromstr branch January 31, 2022 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants