2 // This is a regression test for something that only came up while
3 // attempting to bootstrap librustc with new destructor lifetime
7 use std::collections::HashMap;
8 use std::cell::RefCell;
10 // This version does not yet work (associated type issues)...
11 #[cfg(cannot_use_this_yet)]
12 fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) {
14 assert_eq!(map.borrow().get("one"), Some(&one[..]));
17 #[cfg(cannot_use_this_yet_either)]
18 // ... and this version does not work (the lifetime of `one` is
19 // supposed to match the lifetime `'a`) ...
20 fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) {
22 assert_eq!(map.borrow().get("one"), Some(&&one[..]));
25 #[cfg(all(not(cannot_use_this_yet),not(cannot_use_this_yet_either)))]
26 fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) {
27 // ...so instead we walk through the trivial slice and make sure
28 // it contains the element we expect.
30 for (i, &x) in map.borrow().get("one").unwrap().iter().enumerate() {
31 assert_eq!((i, x), (0, 1));
39 let mut map = HashMap::new();
40 map.insert("zero", &zer[..]);
41 map.insert("one", &one[..]);
42 map.insert("two", &two[..]);
43 let map = RefCell::new(map);