Skip to content

Commit 86f332d

Browse files
CoAlloc: Vec + slice: COOP_PREFERRED
1 parent f47ce34 commit 86f332d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

library/alloc/src/slice.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,14 @@ impl<T> [T] {
456456
#[rustc_conversion_suggestion]
457457
#[stable(feature = "rust1", since = "1.0.0")]
458458
#[inline]
459-
pub fn to_vec(&self) -> Vec<T>
459+
pub fn to_vec<const COOP_PREFERRED: bool>(&self) -> Vec<T, Global, COOP_PREFERRED>
460460
where
461461
T: Clone,
462+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(
463+
COOP_PREFERRED,
464+
)]:,
462465
{
463-
self.to_vec_in(Global)
466+
self.to_vec_in::<Global, COOP_PREFERRED>(Global)
464467
}
465468

466469
/// Copies `self` into a new `Vec` with an allocator.

library/alloc/src/vec/spec_from_iter_nested.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::iter::TrustedLen;
44
use core::ptr;
55

66
use crate::raw_vec::RawVec;
7-
use crate::Global;
7+
use crate::alloc::Global;
88
use crate::DEFAULT_COOP_PREFERRED;
99

1010
use super::{SpecExtend, Vec};

0 commit comments

Comments
 (0)