diff options
| author | The8472 <git@infinite-source.de> | 2019-10-11 20:43:25 +0200 |
|---|---|---|
| committer | The8472 <git@infinite-source.de> | 2020-09-03 20:59:03 +0200 |
| commit | bb2d533bb9b5c247f48f7932f7e533475b59e402 (patch) | |
| tree | fb8d7148dab7b9c75ef9144b18b083bf863d1616 /library/alloc/tests/binary_heap.rs | |
| parent | 038394a330f24e5ec63d78657a32f3279b8b276b (diff) | |
in-place collect for Vec. Box<[]> and BinaryHeap IntoIter and some adapters
Diffstat (limited to 'library/alloc/tests/binary_heap.rs')
| -rw-r--r-- | library/alloc/tests/binary_heap.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/library/alloc/tests/binary_heap.rs b/library/alloc/tests/binary_heap.rs index 62084ccf53c..ce794a9a4af 100644 --- a/library/alloc/tests/binary_heap.rs +++ b/library/alloc/tests/binary_heap.rs @@ -231,6 +231,18 @@ fn test_to_vec() { } #[test] +fn test_in_place_iterator_specialization() { + let src: Vec<usize> = vec![1, 2, 3]; + let src_ptr = src.as_ptr(); + let heap: BinaryHeap<_> = src.into_iter().map(std::convert::identity).collect(); + let heap_ptr = heap.iter().next().unwrap() as *const usize; + assert_eq!(src_ptr, heap_ptr); + let sink: Vec<_> = heap.into_iter().map(std::convert::identity).collect(); + let sink_ptr = sink.as_ptr(); + assert_eq!(heap_ptr, sink_ptr); +} + +#[test] fn test_empty_pop() { let mut heap = BinaryHeap::<i32>::new(); assert!(heap.pop().is_none()); |
