about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-12-20 20:25:42 +0000
committerbors <bors@rust-lang.org>2022-12-20 20:25:42 +0000
commit1d12c3cea30b8ba4a09650a9e9c46fe9fbe25f0b (patch)
tree13b5df3443dbc5d93e5c765d374e69861bfe27fa
parentd6da428f343ab811b2b132364360ba13ff05830c (diff)
parent2fba07842b2553f5abaada91590817032df36f7d (diff)
downloadrust-1d12c3cea30b8ba4a09650a9e9c46fe9fbe25f0b.tar.gz
rust-1d12c3cea30b8ba4a09650a9e9c46fe9fbe25f0b.zip
Auto merge of #105127 - Sp00ph:const_new, r=dtolnay
Make `VecDeque::new` const

(See #105072)
-rw-r--r--library/alloc/src/collections/vec_deque/mod.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs
index be615b70ced..c955db46d29 100644
--- a/library/alloc/src/collections/vec_deque/mod.rs
+++ b/library/alloc/src/collections/vec_deque/mod.rs
@@ -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.