Skip to content

Commit 2fba078

Browse files
committed
Make VecDeque::new const
1 parent e0098a5 commit 2fba078

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
@@ -531,12 +531,13 @@ impl<T> VecDeque<T> {
531531
///
532532
/// let deque: VecDeque<u32> = VecDeque::new();
533533
/// ```
534-
// FIXME: This should probably be const
535534
#[inline]
536535
#[stable(feature = "rust1", since = "1.0.0")]
536+
#[rustc_const_stable(feature = "const_vec_deque_new", since = "CURRENT_RUSTC_VERSION")]
537537
#[must_use]
538-
pub fn new() -> VecDeque<T> {
539-
VecDeque::new_in(Global)
538+
pub const fn new() -> VecDeque<T> {
539+
// FIXME: This should just be `VecDeque::new_in(Global)` once that hits stable.
540+
VecDeque { head: 0, len: 0, buf: RawVec::NEW }
540541
}
541542

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

0 commit comments

Comments
 (0)