Skip to content

Commit

Permalink
Auto merge of rust-lang#105127 - Sp00ph:const_new, r=dtolnay
Browse files Browse the repository at this point in the history
Make `VecDeque::new` const

(See rust-lang#105072)
  • Loading branch information
bors committed Dec 20, 2022
2 parents d6da428 + 2fba078 commit 1d12c3c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions library/alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,13 @@ impl<T> VecDeque<T> {
///
/// let deque: VecDeque<u32> = VecDeque::new();
/// ```
// FIXME: This should probably be const
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_vec_deque_new", since = "CURRENT_RUSTC_VERSION")]
#[must_use]
pub fn new() -> VecDeque<T> {
VecDeque::new_in(Global)
pub const fn new() -> VecDeque<T> {
// FIXME: This should just be `VecDeque::new_in(Global)` once that hits stable.
VecDeque { head: 0, len: 0, buf: RawVec::NEW }
}

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

0 comments on commit 1d12c3c

Please sign in to comment.