Skip to content

Commit 327b94a

Browse files
committed
Make VecDeque::{new,new_in} const fns
1 parent 19e6695 commit 327b94a

File tree

1 file changed

+5
-5
lines changed
  • library/alloc/src/collections/vec_deque

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
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 = "1.67.0")]
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's stable.
540+
VecDeque { head: 0, len: 0, buf: RawVec::NEW }
540541
}
541542

542543
/// Creates an empty deque with space for at least `capacity` elements.
@@ -566,10 +567,9 @@ impl<T, A: Allocator> VecDeque<T, A> {
566567
///
567568
/// let deque: VecDeque<u32> = VecDeque::new();
568569
/// ```
569-
// FIXME: This should probably be const
570570
#[inline]
571571
#[unstable(feature = "allocator_api", issue = "32838")]
572-
pub fn new_in(alloc: A) -> VecDeque<T, A> {
572+
pub const fn new_in(alloc: A) -> VecDeque<T, A> {
573573
VecDeque { head: 0, len: 0, buf: RawVec::new_in(alloc) }
574574
}
575575

0 commit comments

Comments
 (0)