• Home
  • Raw
  • Download

Lines Matching refs:map

42     let mut map = LinkedHashMap::new();  in test_index()  localVariable
43 map.insert(1, 10); in test_index()
44 map.insert(2, 20); in test_index()
45 assert_eq!(10, map[&1]); in test_index()
46 map[&2] = 22; in test_index()
47 assert_eq!(22, map[&2]); in test_index()
52 let mut map = LinkedHashMap::new(); in test_insert_and_get() localVariable
53 map.insert(1, 10); in test_insert_and_get()
54 map.insert(2, 20); in test_insert_and_get()
55 assert_eq!(map.get(&1), Some(&10)); in test_insert_and_get()
56 assert_eq!(map.get(&2), Some(&20)); in test_insert_and_get()
57 assert_eq!(map.len(), 2); in test_insert_and_get()
62 let mut map = LinkedHashMap::new(); in test_insert_update() localVariable
63 map.insert("1".to_string(), vec![10, 10]); in test_insert_update()
64 map.insert("1".to_string(), vec![10, 19]); in test_insert_update()
65 assert_eq!(map.get(&"1".to_string()), Some(&vec![10, 19])); in test_insert_update()
66 assert_eq!(map.len(), 1); in test_insert_update()
71 let mut map = LinkedHashMap::new(); in test_entry_insert_vacant() localVariable
72 match map.entry("1".to_string()) { in test_entry_insert_vacant()
78 assert!(map.contains_key("1")); in test_entry_insert_vacant()
79 assert_eq!(map["1"], vec![10, 10]); in test_entry_insert_vacant()
81 match map.entry("1".to_string()) { in test_entry_insert_vacant()
89 assert!(map.contains_key("1")); in test_entry_insert_vacant()
90 assert_eq!(map["1"], vec![10, 16]); in test_entry_insert_vacant()
92 match map.entry("1".to_string()) { in test_entry_insert_vacant()
102 let mut map = LinkedHashMap::new(); in test_remove() localVariable
103 map.insert(1, 10); in test_remove()
104 map.insert(2, 20); in test_remove()
105 map.insert(3, 30); in test_remove()
106 map.insert(4, 40); in test_remove()
107 map.insert(5, 50); in test_remove()
108 map.remove(&3); in test_remove()
109 map.remove(&4); in test_remove()
110 assert!(map.get(&3).is_none()); in test_remove()
111 assert!(map.get(&4).is_none()); in test_remove()
112 map.insert(6, 60); in test_remove()
113 map.insert(7, 70); in test_remove()
114 map.insert(8, 80); in test_remove()
115 assert_eq!(map.get(&6), Some(&60)); in test_remove()
116 assert_eq!(map.get(&7), Some(&70)); in test_remove()
117 assert_eq!(map.get(&8), Some(&80)); in test_remove()
122 let mut map = LinkedHashMap::new(); in test_pop() localVariable
123 map.insert(1, 10); in test_pop()
124 map.insert(2, 20); in test_pop()
125 map.insert(3, 30); in test_pop()
126 map.insert(4, 40); in test_pop()
127 map.insert(5, 50); in test_pop()
128 assert_eq!(map.pop_front(), Some((1, 10))); in test_pop()
129 assert!(map.get(&1).is_none()); in test_pop()
130 assert_eq!(map.pop_back(), Some((5, 50))); in test_pop()
131 assert!(map.get(&5).is_none()); in test_pop()
132 map.insert(6, 60); in test_pop()
133 map.insert(7, 70); in test_pop()
134 map.insert(8, 80); in test_pop()
135 assert_eq!(map.pop_front(), Some((2, 20))); in test_pop()
136 assert!(map.get(&2).is_none()); in test_pop()
137 assert_eq!(map.pop_back(), Some((8, 80))); in test_pop()
138 assert!(map.get(&8).is_none()); in test_pop()
139 map.insert(3, 30); in test_pop()
140 assert_eq!(map.pop_front(), Some((4, 40))); in test_pop()
141 assert!(map.get(&4).is_none()); in test_pop()
142 assert_eq!(map.pop_back(), Some((3, 30))); in test_pop()
143 assert!(map.get(&3).is_none()); in test_pop()
148 let to_back = |map: &mut LinkedHashMap<_, _>, key| match map.entry(key) { in test_move()
153 let to_front = |map: &mut LinkedHashMap<_, _>, key| match map.entry(key) { in test_move()
158 let mut map = LinkedHashMap::new(); in test_move() localVariable
159 map.insert(1, 10); in test_move()
160 map.insert(2, 20); in test_move()
161 map.insert(3, 30); in test_move()
162 map.insert(4, 40); in test_move()
163 map.insert(5, 50); in test_move()
165 to_back(&mut map, 1); in test_move()
166 assert_eq!(map.keys().copied().collect::<Vec<_>>(), vec![2, 3, 4, 5, 1]); in test_move()
168 to_front(&mut map, 4); in test_move()
169 assert_eq!(map.keys().copied().collect::<Vec<_>>(), vec![4, 2, 3, 5, 1]); in test_move()
171 to_back(&mut map, 3); in test_move()
172 assert_eq!(map.keys().copied().collect::<Vec<_>>(), vec![4, 2, 5, 1, 3]); in test_move()
174 to_front(&mut map, 2); in test_move()
175 assert_eq!(map.keys().copied().collect::<Vec<_>>(), vec![2, 4, 5, 1, 3]); in test_move()
177 to_back(&mut map, 3); in test_move()
178 assert_eq!(map.keys().copied().collect::<Vec<_>>(), vec![2, 4, 5, 1, 3]); in test_move()
180 to_front(&mut map, 2); in test_move()
181 assert_eq!(map.keys().copied().collect::<Vec<_>>(), vec![2, 4, 5, 1, 3]); in test_move()
186 let mut map = LinkedHashMap::new(); in test_clear() localVariable
187 map.insert(1, 10); in test_clear()
188 map.insert(2, 20); in test_clear()
189 map.clear(); in test_clear()
190 assert!(map.get(&1).is_none()); in test_clear()
191 assert!(map.get(&2).is_none()); in test_clear()
192 assert!(map.is_empty()); in test_clear()
197 let mut map = LinkedHashMap::new(); in test_iter() localVariable
200 assert_eq!(None, map.iter().next()); in test_iter()
202 map.insert("a", 10); in test_iter()
203 map.insert("b", 20); in test_iter()
204 map.insert("c", 30); in test_iter()
207 let mut iter = map.iter(); in test_iter()
214 let mut iter = map.iter(); in test_iter()
223 let mut rev_iter = map.iter().rev(); in test_iter()
231 let mut mixed_iter = map.iter(); in test_iter()
252 let mut map = LinkedHashMap::new(); in test_borrow() localVariable
253 map.insert(Foo(Bar(1)), "a"); in test_borrow()
254 map.insert(Foo(Bar(2)), "b"); in test_borrow()
256 assert!(map.contains_key(&Bar(1))); in test_borrow()
257 assert!(map.contains_key(&Bar(2))); in test_borrow()
258 assert!(map.contains_key(&Foo(Bar(1)))); in test_borrow()
259 assert!(map.contains_key(&Foo(Bar(2)))); in test_borrow()
261 assert_eq!(map.get(&Bar(1)), Some(&"a")); in test_borrow()
262 assert_eq!(map.get(&Bar(2)), Some(&"b")); in test_borrow()
263 assert_eq!(map.get(&Foo(Bar(1))), Some(&"a")); in test_borrow()
264 assert_eq!(map.get(&Foo(Bar(2))), Some(&"b")); in test_borrow()
266 assert_eq!(map.get_mut(&Bar(1)), Some(&mut "a")); in test_borrow()
267 assert_eq!(map.get_mut(&Bar(2)), Some(&mut "b")); in test_borrow()
268 assert_eq!(map.get_mut(&Foo(Bar(1))), Some(&mut "a")); in test_borrow()
269 assert_eq!(map.get_mut(&Foo(Bar(2))), Some(&mut "b")); in test_borrow()
271 assert_eq!(map[&Bar(1)], "a"); in test_borrow()
272 assert_eq!(map[&Bar(2)], "b"); in test_borrow()
273 assert_eq!(map[&Foo(Bar(1))], "a"); in test_borrow()
274 assert_eq!(map[&Foo(Bar(2))], "b"); in test_borrow()
276 assert_eq!(map.remove(&Bar(1)), Some("a")); in test_borrow()
277 assert_eq!(map.remove(&Bar(2)), Some("b")); in test_borrow()
278 assert_eq!(map.remove(&Foo(Bar(1))), None); in test_borrow()
279 assert_eq!(map.remove(&Foo(Bar(2))), None); in test_borrow()
284 let mut map = LinkedHashMap::new(); in test_iter_mut() localVariable
285 map.insert("a", 10); in test_iter_mut()
286 map.insert("c", 30); in test_iter_mut()
287 map.insert("b", 20); in test_iter_mut()
290 let mut iter = map.iter_mut(); in test_iter_mut()
309 assert_eq!(17, map[&"a"]); in test_iter_mut()
310 assert_eq!(23, map[&"b"]); in test_iter_mut()
315 let map = { in test_consuming_iter() localVariable
316 let mut map = LinkedHashMap::new(); in test_consuming_iter() localVariable
317 map.insert("a", 10); in test_consuming_iter()
318 map.insert("c", 30); in test_consuming_iter()
319 map.insert("b", 20); in test_consuming_iter()
320 map in test_consuming_iter()
323 let mut iter = map.into_iter(); in test_consuming_iter()
334 let map = LinkedHashMap::<&str, i32>::new(); in test_consuming_iter_empty() localVariable
335 let mut iter = map.into_iter(); in test_consuming_iter_empty()
341 let mut map = LinkedHashMap::new(); in test_consuming_iter_with_free_list() localVariable
342 map.insert("a", 10); in test_consuming_iter_with_free_list()
343 map.insert("c", 30); in test_consuming_iter_with_free_list()
344 map.insert("b", 20); in test_consuming_iter_with_free_list()
345 map.remove("a"); in test_consuming_iter_with_free_list()
346 map.remove("b"); in test_consuming_iter_with_free_list()
348 let mut iter = map.into_iter(); in test_consuming_iter_with_free_list()
368 let mut map = LinkedHashMap::new(); in test_into_iter_drop() localVariable
369 map.insert("a", Counter(&mut a)); in test_into_iter_drop()
370 map.insert("b", Counter(&mut b)); in test_into_iter_drop()
371 map.insert("c", Counter(&mut c)); in test_into_iter_drop()
373 let mut iter = map.into_iter(); in test_into_iter_drop()
374 assert_eq!(iter.next().map(|p| p.0), Some("a")); in test_into_iter_drop()
375 assert_eq!(iter.next_back().map(|p| p.0), Some("c")); in test_into_iter_drop()
395 let mut map = LinkedHashMap::new(); in test_drain() localVariable
401 map.insert("a", Counter(a.clone())); in test_drain()
402 map.insert("b", Counter(b.clone())); in test_drain()
403 map.insert("c", Counter(c.clone())); in test_drain()
405 let mut iter = map.drain(); in test_drain()
406 assert_eq!(iter.next().map(|p| p.0), Some("a")); in test_drain()
407 assert_eq!(iter.next_back().map(|p| p.0), Some("c")); in test_drain()
408 assert_eq!(iter.next_back().map(|p| p.0), Some("b")); in test_drain()
413 assert_eq!(map.len(), 0); in test_drain()
419 map.insert("a", Counter(a.clone())); in test_drain()
420 map.insert("b", Counter(b.clone())); in test_drain()
421 map.insert("c", Counter(c.clone())); in test_drain()
423 let mut iter = map.drain(); in test_drain()
424 assert_eq!(iter.next().map(|p| p.0), Some("a")); in test_drain()
425 assert_eq!(iter.next().map(|p| p.0), Some("b")); in test_drain()
426 assert_eq!(iter.next_back().map(|p| p.0), Some("c")); in test_drain()
431 assert_eq!(map.len(), 0); in test_drain()
437 map.insert("a", Counter(a.clone())); in test_drain()
438 map.insert("b", Counter(b.clone())); in test_drain()
439 map.insert("c", Counter(c.clone())); in test_drain()
441 map.drain(); in test_drain()
442 assert_eq!(map.len(), 0); in test_drain()
470 let mut map: LinkedHashMap<String, i32> = xs.iter().map(|i| (i.to_string(), *i)).collect(); in test_retain() localVariable
471 map.retain(|_, v| *v % 2 == 0); in test_retain()
472 assert_eq!(map.len(), 3); in test_retain()
473 assert!(map.contains_key("2")); in test_retain()
474 assert!(map.contains_key("4")); in test_retain()
475 assert!(map.contains_key("6")); in test_retain()
487 let mut map = LinkedHashMap::new(); in test_retain() localVariable
488 map.insert(1, Counter(Rc::clone(&c))); in test_retain()
489 map.insert(2, Counter(Rc::clone(&c))); in test_retain()
490 map.insert(3, Counter(Rc::clone(&c))); in test_retain()
491 map.insert(4, Counter(Rc::clone(&c))); in test_retain()
493 map.retain(|k, _| *k % 2 == 0); in test_retain()
496 drop(map); in test_retain()
503 let mut map1: LinkedHashMap<String, i32> = xs.iter().map(|i| (i.to_string(), *i)).collect(); in test_order_equality()
504 let mut map2: LinkedHashMap<String, i32> = xs.iter().map(|i| (i.to_string(), *i)).collect(); in test_order_equality()
517 let mut map = LinkedHashMap::new(); in test_replace() localVariable
519 map.insert(1, 1); in test_replace()
520 map.insert(2, 2); in test_replace()
521 map.insert(3, 3); in test_replace()
522 map.insert(4, 4); in test_replace()
524 assert!(map in test_replace()
526 .map(|(k, v)| (*k, *v)) in test_replace()
529 map.insert(3, 5); in test_replace()
531 assert!(map in test_replace()
533 .map(|(k, v)| (*k, *v)) in test_replace()
536 map.replace(2, 6); in test_replace()
538 assert!(map in test_replace()
540 .map(|(k, v)| (*k, *v)) in test_replace()
546 let mut map = LinkedHashMap::new(); in test_shrink_to_fit_resize() localVariable
547 map.shrink_to_fit(); in test_shrink_to_fit_resize()
550 map.insert(i, i); in test_shrink_to_fit_resize()
552 map.shrink_to_fit(); in test_shrink_to_fit_resize()
555 map.pop_front(); in test_shrink_to_fit_resize()
556 map.shrink_to_fit(); in test_shrink_to_fit_resize()
559 assert_eq!(map.len(), 50); in test_shrink_to_fit_resize()
561 assert_eq!(map.get(&i).unwrap(), &i); in test_shrink_to_fit_resize()