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:
commit
b72db84fd0
@ -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 }
|
||||
}
|
||||
}
|
||||
|
@ -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) }
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user