mirror of
https://github.com/rust-lang/rust.git
synced 2025-12-30 06:05:29 +00:00
constify some `CStr` methods
This PR marks the following public APIs as `const`:
```rust
impl CStr {
// feature(const_cstr_from_bytes)
pub const fn from_bytes_until_nul(bytes: &[u8]) -> Result<&CStr, FromBytesUntilNulError>;
pub const fn from_bytes_with_nul(bytes: &[u8]) -> Result<&Self, FromBytesWithNulError>;
// feature(const_cstr_to_bytes)
pub const fn to_bytes(&self) -> &[u8];
pub const fn to_bytes_with_nul(&self) -> &[u8];
pub const fn to_str(&self) -> Result<&str, str::Utf8Error>;
}
```
r? ```@oli-obk``` (use of `const_eval_select` :P )
cc ```@mina86``` (you've asked for this <3 )