Skip to content

Commit

Permalink
Make VecDeque::{new,new_in} const fns
Browse files Browse the repository at this point in the history
  • Loading branch information
Sp00ph committed Nov 29, 2022
1 parent 19e6695 commit 327b94a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 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 = "1.67.0")]
#[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's stable.
VecDeque { head: 0, len: 0, buf: RawVec::NEW }
}

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

Expand Down

0 comments on commit 327b94a

Please sign in to comment.