Auto merge of #105127 - Sp00ph:const_new, r=dtolnay
Make `VecDeque::new` const (See #105072)
This commit is contained in:
commit
1d12c3cea3
1 changed files with 4 additions and 3 deletions
|
@ -535,12 +535,13 @@ impl<T> VecDeque<T> {
|
||||||
///
|
///
|
||||||
/// let deque: VecDeque<u32> = VecDeque::new();
|
/// let deque: VecDeque<u32> = VecDeque::new();
|
||||||
/// ```
|
/// ```
|
||||||
// FIXME: This should probably be const
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[rustc_const_stable(feature = "const_vec_deque_new", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new() -> VecDeque<T> {
|
pub const fn new() -> VecDeque<T> {
|
||||||
VecDeque::new_in(Global)
|
// 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.
|
/// Creates an empty deque with space for at least `capacity` elements.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue