rust/tests/run-pass/btreemap.rs

30 lines
662 B
Rust
Raw Normal View History

2019-02-13 10:22:06 -06:00
use std::collections::{BTreeMap, BTreeSet};
2017-08-28 07:10:59 -05:00
#[derive(PartialEq, Eq, PartialOrd, Ord)]
pub enum Foo {
A(&'static str),
_B,
_C,
}
pub fn main() {
2019-02-13 10:22:06 -06:00
let mut b = BTreeSet::new();
2017-08-28 07:10:59 -05:00
b.insert(Foo::A("\'"));
b.insert(Foo::A("/="));
b.insert(Foo::A("#"));
b.insert(Foo::A("0o"));
assert!(b.remove(&Foo::A("/=")));
assert!(!b.remove(&Foo::A("/=")));
2019-02-13 10:22:06 -06:00
// Also test a lower-alignment type, where the NodeHeader overlaps with
// the keys.
let mut b = BTreeSet::new();
b.insert(1024);
b.insert(7);
let mut b = BTreeMap::new();
b.insert("bar", 1024);
b.insert("baz", 7);
for _val in b.iter_mut() {}
2017-08-28 07:10:59 -05:00
}