Skip to content

Commit 9a97668

Browse files
committed
Auto merge of #159917 - bend-n:split_at_capacity_constifications, r=<try>
spare capacity mut constification try-job: x86_64-mingw
2 parents 9451e06 + b8fd8a8 commit 9a97668

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

library/alloc/src/vec/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3302,8 +3302,9 @@ impl<T, A: Allocator> Vec<T, A> {
33023302
/// assert_eq!(&v, &[0, 1, 2]);
33033303
/// ```
33043304
#[stable(feature = "vec_spare_capacity", since = "1.60.0")]
3305+
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
33053306
#[inline]
3306-
pub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>] {
3307+
pub const fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>] {
33073308
// Note:
33083309
// This method is not implemented in terms of `split_at_spare_mut`,
33093310
// to prevent invalidation of pointers to the buffer.
@@ -3367,8 +3368,9 @@ impl<T, A: Allocator> Vec<T, A> {
33673368
/// assert_eq!(&v, &[1, 1, 2, 4, 8, 12, 16]);
33683369
/// ```
33693370
#[unstable(feature = "vec_split_at_spare", issue = "81944")]
3371+
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
33703372
#[inline]
3371-
pub fn split_at_spare_mut(&mut self) -> (&mut [T], &mut [MaybeUninit<T>]) {
3373+
pub const fn split_at_spare_mut(&mut self) -> (&mut [T], &mut [MaybeUninit<T>]) {
33723374
// SAFETY:
33733375
// - len is ignored and so never changed
33743376
let (init, spare, _) = unsafe { self.split_at_spare_mut_with_len() };
@@ -3378,7 +3380,7 @@ impl<T, A: Allocator> Vec<T, A> {
33783380
/// Safety: changing returned .2 (&mut usize) is considered the same as calling `.set_len(_)`.
33793381
///
33803382
/// This method provides unique access to all vec parts at once in `extend_from_within`.
3381-
unsafe fn split_at_spare_mut_with_len(
3383+
const unsafe fn split_at_spare_mut_with_len(
33823384
&mut self,
33833385
) -> (&mut [T], &mut [MaybeUninit<T>], &mut usize) {
33843386
let ptr = self.as_mut_ptr();

0 commit comments

Comments
 (0)