-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Tracking Issue for os_str_display
#120048
Comments
Add `display` method to `OsStr` Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode. Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`. This change also makes the `std::ffi::os_str` module public (see rust-lang/libs-team#326 (comment)). - ACP: rust-lang/libs-team#326 - Tracking issue: rust-lang#120048
Add `display` method to `OsStr` Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode. Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`. This change also makes the `std::ffi::os_str` module public (see rust-lang/libs-team#326 (comment)). - ACP: rust-lang/libs-team#326 - Tracking issue: rust-lang#120048
Add `display` method to `OsStr` Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode. Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`. This change also makes the `std::ffi::os_str` module public (see rust-lang/libs-team#326 (comment)). - ACP: rust-lang/libs-team#326 - Tracking issue: rust-lang#120048
Add `display` method to `OsStr` Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode. Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`. This change also makes the `std::ffi::os_str` module public (see rust-lang/libs-team#326 (comment)). - ACP: rust-lang/libs-team#326 - Tracking issue: rust-lang#120048
Add `display` method to `OsStr` Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode. Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`. This change also makes the `std::ffi::os_str` module public (see rust-lang/libs-team#326 (comment)). - ACP: rust-lang/libs-team#326 - Tracking issue: rust-lang#120048
Rollup merge of rust-lang#120051 - riverbl:os-str-display, r=m-ou-se Add `display` method to `OsStr` Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode. Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`. This change also makes the `std::ffi::os_str` module public (see rust-lang/libs-team#326 (comment)). - ACP: rust-lang/libs-team#326 - Tracking issue: rust-lang#120048
I'm concerned about the name. I think These methods are really only suitable for use in diagnostics. Places where the stringlike thing is transformed for further use must necessarily either give up on handling invalid unicode (so should use a fallible method) or do something more complicated and awkward. |
(Worst case behaviour from inappropriate use of these methods is modifying the wrong file.) |
I've encountered situations where |
This is an idea stolen from rust-lang/rust#120048. It's useful for the next commit.
This is an idea stolen from rust-lang/rust#120048. It's useful for the next commit.
Are there any objections to stabilising this? It's been close to a year. |
@rfcbot fcp merge |
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. |
Apparently my earlier comment #120048 (comment) was unclear. I object to stabilising this with this name. It should be called That the analogous method on
For the avoidance of doubt, yes, I agree that this method is useful and ought to exist. All I mean is that it should have (I would also love to try to deprecate |
I don't think that there is anything inherent that says display must equate to lossless. The Additionally, I don't see why |
Display is not in general expected to be lossless. The fact that you have to call |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
I agree with @joshtriplett here, and to add, I also put some value on making this consistent in name with |
Where is this currently stated? I think it needs to be a lot more prominent. For example, it's not stated in the trait docs for |
It's not necessary (or possible) to list every allowed behaviour of a trait. One can usually assume that a specific implementation is allowed as long as the opposite isn't explicitely stated. |
I'm sorry to say that this is not the attitude I normally expect within the Rust community. We should be trying to help Rust programmers write correct software. That means absolutely not accepting "the implementation is allowed to do anything that's not explicitly forbidden". That way lies C. I might be persuaded if this were some obscure detail. But it's not. It's core to the semantics of the whole trait (and of As I say, trying to use something that came from At the very least we should explain that this is not the intended use of |
That might make a good clippy lint to add. |
I submitted PR #136687 to expand the documentation and document the established practice that |
Feature gate:
#![feature(os_str_display)]
This is a tracking issue for the
OsStr::display
method.Public API
Steps / History
OsStr::display
(similar toPath::display
) libs-team#326display
method toOsStr
#120051Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: