-
Notifications
You must be signed in to change notification settings - Fork 13k
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 CString, OsString, PathBuf extra methods #40380
Comments
ping @brson / @alexcrichton to tag this, also ping @jonhoo because you were specifically interested in stabilising these for something for serde. |
Oh it looks like in #39594 we forgot to update the tracking issue. @clarcharr could you update those tracking issues to point here? |
I included that as part of the second PR, so, already covered. If for some reason that PR isn't accepted, I'll make a separate PR for just updating the tracking issues. |
Reduce str transmutes, add mut versions of methods. When I was working on the various parts involved in #40380 one of the comments I got was the excess of transmutes necessary to make the changes work. This is part of a set of multiple changes I'd like to offer to fix this problem. I think that having these methods is reasonable because they're already possible via transmutes, and it makes the code that uses them safer. I can also add `pub(crate)` to these methods for now if the libs team would rather not expose them to the public without an RFC.
The into_boxed_* methods do not have associated tracking issue set. Also, I really dislike the |
Currently this is to be consistent with methods that already exist, like |
Also I'm confused on what you mean about them lacking a tracking issue; all of them link to here. |
There’s no tracking issue linked in the stable docs, which is why I was confused. |
I initially forgot to add a tracking issue before the cut, so, they're probably on the beta docs but not stable. I thought that I had gotten it in before the changes were merged but I guess not. |
Is there a way we could get this on track for stabilisation? This is necessary to make some (I am not sure how to tag the libs team in general) |
Sure yeah, let's see what others think: @rfcbot fcp merge |
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, 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. |
So far I have only looked at It looks like the implementation could be simpler: pub fn as_c_str(&self) -> &CStr {
self
} This is what Also I noticed there is What are the reasons that people use |
I personally use it a lot via map, e.g. There's no |
This was in the insta-stable part of #40009 but this impl has a stray lifetime that should be removed. EDIT: also this impl. The attribute on that impl says I'm sure this has been discussed but there is no way to do any of the Changing them to These are the very first |
@dtolnay First, thank you for looking into this so much! So, sort-of in order:
|
Clarify docs on implementing Into. This was suggested by @dtolnay in rust-lang#40380. This explicitly clarifies in what circumstances you should implement `Into` instead of `From`.
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period is now complete. |
Stabilizes: * `CString::as_c_str` * `CString::into_boxed_c_str` * `CStr::into_c_string` * `OsString::into_boxed_os_str` * `OsStr::into_os_string` * `PathBuf::into_boxed_path` * `PathBuf::into_path_buf` Closes rust-lang#40380
This includes the methods:
CString::into_boxed_c_str
OsString::into_boxed_os_str
PathBuf::into_boxed_path
<Box<CStr>>::into_c_string
<Box<OsStr>>::into_os_string
<Box<Path>>::into_path_buf
CString::as_c_str
The
into_boxed_*
methods coming from #39594, the otherinto_*
methods from #40009, and theas_c_str
method from #41095.The features for the methods are
into_boxed_c_str
,into_boxed_os_str
,into_boxed_path
, andas_c_str
.The text was updated successfully, but these errors were encountered: