Conversation
|
r? @scottmcm (rust-highfive has picked a reviewer for you, use r? to override) |
|
r? @oli-obk |
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
|
Thanks. LGTM. |
oli-obk
left a comment
There was a problem hiding this comment.
Oops forgot to send off the review
library/core/src/ffi/c_str.rs
Outdated
There was a problem hiding this comment.
use the same feature gate and issue as the regular unstable attribute, these can be stabilized together.
There was a problem hiding this comment.
Should I open an issues for from_bytes_with_nul and to_bytes/to_bytes_with_nul/to_str? (they are stable, so I can't reuse the feature gate/issue)
There was a problem hiding this comment.
Yea, I think it's best to track them. You could just munge them into a generic cstr_consts gate and make one issue for all of them
library/core/src/slice/memchr.rs
Outdated
There was a problem hiding this comment.
I appreciate the ingenuity, but why not just while let i < bytes.len() and index with i?
There was a problem hiding this comment.
I do not remember, probably because of a habit, I think there was a time when you couldn't index in const fns, but could use patterns.
c54464a to
cb02b64
Compare
|
@bors r+ rollup |
…=oli-obk
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 )
…=oli-obk
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 )
…llaumeGomez Rollup of 8 pull requests Successful merges: - rust-lang#100185 (Fix `ReErased` leaking into typeck due to `typeof(...)` recovery) - rust-lang#100291 (constify some `CStr` methods) - rust-lang#101677 (Add test for rust-lang#101211) - rust-lang#101723 (Impove diagnostic for `.await`ing non-futures) - rust-lang#101724 (Allow unauthenticated users to add the `const-hack` label) - rust-lang#101731 (rustdoc: improve rustdoc HTML suggestions handling of nested generics) - rust-lang#101732 (Feature gate the `rustdoc::missing_doc_code_examples` lint) - rust-lang#101735 (rustdoc: fix treatment of backslash-escaped HTML) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This PR marks the following public APIs as
const:r? @oli-obk (use of
const_eval_select:P )cc @mina86 (you've asked for this <3 )