-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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_vec_string_slice
#129041
Comments
This would be very useful for For example: struct Foo(Cow<'static, [u32]>);
impl Foo {
// Initialize with heap-allocated data at runtime.
fn heap(data: Vec<u32>) -> Self {
Foo(Cow::Owned(data))
}
// Initialize with static data at compile-time.
const fn static(data: &'static [u32]) -> Self {
Foo(Cow::Borrowed(data))
}
// Access the data, possibly at compile-time, possibly at runtime.
const fn data(&self) -> &[u32] {
match self.0 {
Cow::Borrowed(slice) => slice,
Cow::Owned(vec) => vec.as_slice(),
}
}
} |
This change `const`-qualifies many methods on Vec and String, notably `as_slice`, `as_str`, `len`. These changes are made behind the unstable feature flag `const_vec_string_slice` with the following tracking issue: rust-lang#129041
This change `const`-qualifies many methods on Vec and String, notably `as_slice`, `as_str`, `len`. These changes are made behind the unstable feature flag `const_vec_string_slice` with the following tracking issue: rust-lang#129041
This change `const`-qualifies many methods on Vec and String, notably `as_slice`, `as_str`, `len`. These changes are made behind the unstable feature flag `const_vec_string_slice` with the following tracking issue: rust-lang#129041
This change `const`-qualifies many methods on Vec and String, notably `as_slice`, `as_str`, `len`. These changes are made behind the unstable feature flag `const_vec_string_slice` with the following tracking issue: rust-lang#129041
This change `const`-qualifies many methods on Vec and String, notably `as_slice`, `as_str`, `len`. These changes are made behind the unstable feature flag `const_vec_string_slice` with the following tracking issue: rust-lang#129041
This change `const`-qualifies many methods on Vec and String, notably `as_slice`, `as_str`, `len`. These changes are made behind the unstable feature flag `const_vec_string_slice` with the following tracking issue: rust-lang#129041
This change `const`-qualifies many methods on Vec and String, notably `as_slice`, `as_str`, `len`. These changes are made behind the unstable feature flag `const_vec_string_slice` with the following tracking issue: rust-lang#129041
This change `const`-qualifies many methods on Vec and String, notably `as_slice`, `as_str`, `len`. These changes are made behind the unstable feature flag `const_vec_string_slice` with the following tracking issue: rust-lang#129041
This change `const`-qualifies many methods on Vec and String, notably `as_slice`, `as_str`, `len`. These changes are made behind the unstable feature flag `const_vec_string_slice` with the following tracking issue: rust-lang#129041
@rust-lang/libs-api from a const-eval perspective, these functions all look totally harmless. One can't actually construct non-trivial |
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. |
🔔 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. |
The issue description is missing checkmark in FCP. |
This feature was approved for stabilization in rust-lang#129041 (comment) so this change stabilizes it.
This feature was approved for stabilization in rust-lang#129041 (comment) so this change stabilizes it.
As @RalfJung mentioned on the PR, there are a few methods gated by this feature that were not mentioned in the tracking issue or FCP links: impl String {
pub const fn as_mut_str(&mut self) -> &mut str;
pub const unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8>;
}
impl Vec<T> {
pub const fn as_mut_slice(&mut self) -> &mut [T];
pub const fn as_mut_ptr(&mut self) -> *mut T;
} Libs-api could you take a look at these? @rustbot label +I-libs-api-nominated |
I started a new FCP on #137319. |
This feature was approved for stabilization in rust-lang#129041 (comment) so this change stabilizes it.
This feature was approved for stabilization in rust-lang#129041 (comment) so this change stabilizes it.
This feature was approved for stabilization in rust-lang#129041 (comment) so this change stabilizes it.
…-slice, r=dtolnay Stabilize `const_vec_string_slice` This feature was approved for stabilization in rust-lang#129041 (comment) so this change stabilizes it.
…-slice, r=dtolnay Stabilize `const_vec_string_slice` This feature was approved for stabilization in rust-lang#129041 (comment) so this change stabilizes it.
Rollup merge of rust-lang#137319 - Kixunil:stabilize-const-vec-string-slice, r=dtolnay Stabilize `const_vec_string_slice` This feature was approved for stabilization in rust-lang#129041 (comment) so this change stabilizes it.
This feature was approved for stabilization in rust-lang#129041 (comment) so this change stabilizes it.
Feature gate:
#![feature(const_vec_string_slice)]
This is a tracking issue for making a bunch of
String
andVec
methodsconst
.Public API
The following methods are now
const
:A few additional methods are under this feature gate but were not included in the FCP at #129041 (comment); they got FCP'd in #137319 (comment):
Steps / History
const_vec_string_slice
#137319Unresolved Questions
@rustbot label A-str
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: