diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2023-10-10 18:44:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-10 18:44:46 +0200 |
| commit | b72db84fd054d41546ed45a07c02091fae62a4aa (patch) | |
| tree | 099c7dd89ccc99f0dc62635ce602a303cc4e5b2f | |
| parent | fccf9ec22488c778df012345f58c5f49be756fce (diff) | |
| parent | d60b43c06aad0b181b72ba5ed389961436ac1609 (diff) | |
| download | rust-b72db84fd054d41546ed45a07c02091fae62a4aa.tar.gz rust-b72db84fd054d41546ed45a07c02091fae62a4aa.zip | |
Rollup merge of #116559 - Kritzefitz:btree-new-in-const, r=Amanieu
Mark `new_in` as `const` for BTree collections Discussed in and closes rust-lang/wg-allocators#118
| -rw-r--r-- | library/alloc/src/collections/btree/map.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/set.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 5481b327d69..4bdd9639557 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -669,7 +669,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> { /// map.insert(1, "a"); /// ``` #[unstable(feature = "btreemap_alloc", issue = "32838")] - pub fn new_in(alloc: A) -> BTreeMap<K, V, A> { + pub const fn new_in(alloc: A) -> BTreeMap<K, V, A> { BTreeMap { root: None, length: 0, alloc: ManuallyDrop::new(alloc), _marker: PhantomData } } } diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 9da230915b8..0e03551286e 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -358,7 +358,7 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> { /// let mut set: BTreeSet<i32> = BTreeSet::new_in(Global); /// ``` #[unstable(feature = "btreemap_alloc", issue = "32838")] - pub fn new_in(alloc: A) -> BTreeSet<T, A> { + pub const fn new_in(alloc: A) -> BTreeSet<T, A> { BTreeSet { map: BTreeMap::new_in(alloc) } } |
