about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarkus Everling <markuseverling@gmail.com>2022-12-01 12:13:58 +0100
committerMarkus Everling <markuseverling@gmail.com>2022-12-01 12:41:31 +0100
commit2fba07842b2553f5abaada91590817032df36f7d (patch)
treedf0a2a9ae39b1bd0a9dd754a5636bc54fc75bcee
parente0098a5cc3a87d857e597af824d0ce1ed1ad85e0 (diff)
downloadrust-2fba07842b2553f5abaada91590817032df36f7d.tar.gz
rust-2fba07842b2553f5abaada91590817032df36f7d.zip
Make `VecDeque::new` const
-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 86d77182bcc..30514cbba92 100644
--- a/library/alloc/src/collections/vec_deque/mod.rs
+++ b/library/alloc/src/collections/vec_deque/mod.rs
@@ -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.