Skip to content

Commit 1d12c3c

Browse files
committed
Auto merge of #105127 - Sp00ph:const_new, r=dtolnay
Make `VecDeque::new` const (See #105072)
2 parents d6da428 + 2fba078 commit 1d12c3c

File tree

1 file changed

+4
-3
lines changed
  • library/alloc/src/collections/vec_deque

1 file changed

+4
-3
lines changed

library/alloc/src/collections/vec_deque/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,13 @@ impl<T> VecDeque<T> {
535535
///
536536
/// let deque: VecDeque<u32> = VecDeque::new();
537537
/// ```
538-
// FIXME: This should probably be const
539538
#[inline]
540539
#[stable(feature = "rust1", since = "1.0.0")]
540+
#[rustc_const_stable(feature = "const_vec_deque_new", since = "CURRENT_RUSTC_VERSION")]
541541
#[must_use]
542-
pub fn new() -> VecDeque<T> {
543-
VecDeque::new_in(Global)
542+
pub const fn new() -> VecDeque<T> {
543+
// FIXME: This should just be `VecDeque::new_in(Global)` once that hits stable.
544+
VecDeque { head: 0, len: 0, buf: RawVec::NEW }
544545
}
545546

546547
/// Creates an empty deque with space for at least `capacity` elements.

0 commit comments

Comments
 (0)