Skip to content

Commit

Permalink
Make VecDeque::new const
Browse files Browse the repository at this point in the history
  • Loading branch information
Sp00ph committed Dec 1, 2022
1 parent e0098a5 commit 2fba078
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 @@ -531,12 +531,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 2fba078

Please sign in to comment.