Skip to content

Commit c2eea98

Browse files
CoAlloc: Default for Vec - both coallocation-aware (default fn), and 'standard'.
1 parent a56b09a commit c2eea98

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

library/alloc/src/vec/mod.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3324,7 +3324,20 @@ where
33243324
/// Creates an empty `Vec<T>`.
33253325
///
33263326
/// The vector will not allocate until elements are pushed onto it.
3327-
fn default() -> Vec<T, Global, CO_ALLOC_PREF> {
3327+
default fn default() -> Vec<T, Global, CO_ALLOC_PREF> {
3328+
Vec::new_co()
3329+
}
3330+
}
3331+
3332+
#[stable(feature = "rust1", since = "1.0.0")]
3333+
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
3334+
#[allow(unused_braces)]
3335+
impl<T> const Default for Vec<T>
3336+
{
3337+
/// Creates an empty `Vec<T>`.
3338+
///
3339+
/// The vector will not allocate until elements are pushed onto it.
3340+
fn default() -> Vec<T> {
33283341
Vec::new_co()
33293342
}
33303343
}

0 commit comments

Comments
 (0)