Skip to content

Commit 5a385b4

Browse files
committed
impl [const] Default for BTreeMap
1 parent e7ef22d commit 5a385b4

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

library/alloc/src/collections/btree/map.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2594,7 +2594,8 @@ impl<K: Hash, V: Hash, A: Allocator + Clone> Hash for BTreeMap<K, V, A> {
25942594
}
25952595

25962596
#[stable(feature = "rust1", since = "1.0.0")]
2597-
impl<K, V> Default for BTreeMap<K, V> {
2597+
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
2598+
const impl<K, V> Default for BTreeMap<K, V> {
25982599
/// Creates an empty `BTreeMap`.
25992600
fn default() -> BTreeMap<K, V> {
26002601
BTreeMap::new()

tests/ui/traits/const-traits/const-traits-alloc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
const STRING: String = Default::default();
66
// alloc::vec
77
const VEC: Vec<()> = Default::default();
8+
// alloc::collections::btree::map::BTreeMap
9+
use std::collections::BTreeMap;
10+
const BTREE: BTreeMap<(), ()> = Default::default();
811

912
fn main() {}

0 commit comments

Comments
 (0)