Stabilize const_vec_string_slice
This feature was approved for stabilization in https://github.com/rust-lang/rust/issues/129041#issuecomment-2508940661 so this change stabilizes it.
This commit is contained in:
parent
79b43dfde9
commit
50ea503d9d
3 changed files with 17 additions and 16 deletions
|
@ -1043,7 +1043,8 @@ impl String {
|
|||
#[inline]
|
||||
#[must_use = "`self` will be dropped if the result is not used"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
|
||||
pub const fn into_bytes(self) -> Vec<u8> {
|
||||
self.vec
|
||||
}
|
||||
|
@ -1061,7 +1062,7 @@ impl String {
|
|||
#[must_use]
|
||||
#[stable(feature = "string_as_str", since = "1.7.0")]
|
||||
#[rustc_diagnostic_item = "string_as_str"]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn as_str(&self) -> &str {
|
||||
// SAFETY: String contents are stipulated to be valid UTF-8, invalid contents are an error
|
||||
// at construction.
|
||||
|
@ -1084,7 +1085,7 @@ impl String {
|
|||
#[must_use]
|
||||
#[stable(feature = "string_as_str", since = "1.7.0")]
|
||||
#[rustc_diagnostic_item = "string_as_mut_str"]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn as_mut_str(&mut self) -> &mut str {
|
||||
// SAFETY: String contents are stipulated to be valid UTF-8, invalid contents are an error
|
||||
// at construction.
|
||||
|
@ -1158,7 +1159,7 @@ impl String {
|
|||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn capacity(&self) -> usize {
|
||||
self.vec.capacity()
|
||||
}
|
||||
|
@ -1424,7 +1425,7 @@ impl String {
|
|||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn as_bytes(&self) -> &[u8] {
|
||||
self.vec.as_slice()
|
||||
}
|
||||
|
@ -1778,7 +1779,7 @@ impl String {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8> {
|
||||
&mut self.vec
|
||||
}
|
||||
|
@ -1800,7 +1801,7 @@ impl String {
|
|||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_confusables("length", "size")]
|
||||
pub const fn len(&self) -> usize {
|
||||
self.vec.len()
|
||||
|
@ -1820,7 +1821,7 @@ impl String {
|
|||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn is_empty(&self) -> bool {
|
||||
self.len() == 0
|
||||
}
|
||||
|
|
|
@ -1254,7 +1254,7 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn capacity(&self) -> usize {
|
||||
self.buf.capacity()
|
||||
}
|
||||
|
@ -1569,7 +1569,7 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
#[inline]
|
||||
#[stable(feature = "vec_as_slice", since = "1.7.0")]
|
||||
#[rustc_diagnostic_item = "vec_as_slice"]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn as_slice(&self) -> &[T] {
|
||||
// SAFETY: `slice::from_raw_parts` requires pointee is a contiguous, aligned buffer of size
|
||||
// `len` containing properly-initialized `T`s. Data must not be mutated for the returned
|
||||
|
@ -1601,7 +1601,7 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
#[inline]
|
||||
#[stable(feature = "vec_as_slice", since = "1.7.0")]
|
||||
#[rustc_diagnostic_item = "vec_as_mut_slice"]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn as_mut_slice(&mut self) -> &mut [T] {
|
||||
// SAFETY: `slice::from_raw_parts_mut` requires pointee is a contiguous, aligned buffer of
|
||||
// size `len` containing properly-initialized `T`s. Data must not be accessed through any
|
||||
|
@ -1673,7 +1673,7 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
/// [`as_ptr`]: Vec::as_ptr
|
||||
/// [`as_non_null`]: Vec::as_non_null
|
||||
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_never_returns_null_ptr]
|
||||
#[rustc_as_ptr]
|
||||
#[inline]
|
||||
|
@ -1736,7 +1736,7 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
/// [`as_ptr`]: Vec::as_ptr
|
||||
/// [`as_non_null`]: Vec::as_non_null
|
||||
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_never_returns_null_ptr]
|
||||
#[rustc_as_ptr]
|
||||
#[inline]
|
||||
|
@ -2687,7 +2687,7 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_confusables("length", "size")]
|
||||
pub const fn len(&self) -> usize {
|
||||
let len = self.len;
|
||||
|
@ -2713,7 +2713,7 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_diagnostic_item = "vec_is_empty"]
|
||||
#[rustc_const_unstable(feature = "const_vec_string_slice", issue = "129041")]
|
||||
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn is_empty(&self) -> bool {
|
||||
self.len() == 0
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(const_trait_impl, const_vec_string_slice)]
|
||||
#![feature(const_trait_impl)]
|
||||
|
||||
struct Foo<'a> {
|
||||
bar: &'a mut Vec<usize>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue