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
This commit is contained in:
Guillaume Gomez 2023-10-10 18:44:46 +02:00 committed by GitHub
commit b72db84fd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -669,7 +669,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
/// map.insert(1, "a"); /// map.insert(1, "a");
/// ``` /// ```
#[unstable(feature = "btreemap_alloc", issue = "32838")] #[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 } BTreeMap { root: None, length: 0, alloc: ManuallyDrop::new(alloc), _marker: PhantomData }
} }
} }

View File

@ -358,7 +358,7 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
/// let mut set: BTreeSet<i32> = BTreeSet::new_in(Global); /// let mut set: BTreeSet<i32> = BTreeSet::new_in(Global);
/// ``` /// ```
#[unstable(feature = "btreemap_alloc", issue = "32838")] #[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) } BTreeSet { map: BTreeMap::new_in(alloc) }
} }