-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 const
checked slice to str
conversions
#91006
Comments
@rfcbot merge |
Team member @Amanieu 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. |
Note that cc @oli-obk |
Tracking issue for |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
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. |
…to_str_conv, r=dtolnay Stabilize checked slice->str conversion functions This PR stabilizes the following APIs as `const` functions in Rust 1.63: ```rust // core::str pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error>; impl Utf8Error { pub const fn valid_up_to(&self) -> usize; pub const fn error_len(&self) -> Option<usize>; } ``` Note that the `from_utf8_mut` function is not stabilized as unique references (`&mut _`) are [unstable in const context]. FCP: rust-lang#91006 (comment) [unstable in const context]: rust-lang#57349
Could we also get std::ffi::CStr::to_str covered by this issue? I was hoping this would give me a safe compile-time way to construct str from CStr but currently std::ffi::CStr::to_bytes is not const (for whatever reason) so Alternatively, making std::ffi::CStr::to_bytes const would also work for me. |
…nv, r=dtolnay Stabilize checked slice->str conversion functions This PR stabilizes the following APIs as `const` functions in Rust 1.63: ```rust // core::str pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error>; impl Utf8Error { pub const fn valid_up_to(&self) -> usize; pub const fn error_len(&self) -> Option<usize>; } ``` Note that the `from_utf8_mut` function is not stabilized as unique references (`&mut _`) are [unstable in const context]. FCP: rust-lang/rust#91006 (comment) [unstable in const context]: rust-lang/rust#57349
Feature gate:
#![feature(const_str_from_utf8)]
This is a tracking issue for
str::{from_utf8, from_utf8_mut}
andstr::Utf8Error::{valid_up_to, error_len}
asconst fn
Public API
Public API (stabilized in Rust 1.63)
Steps / History
const
#90607&
functions)&
functions)&mut
function)&mut
function)Unresolved Questions
The text was updated successfully, but these errors were encountered: