File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 11fn main ( ) {
22 let ac = autocfg:: new ( ) ;
33
4+ // Required in order to implement `From<BinaryHeap<T, C>>` for `Vec<T>`.
5+ ac. emit_rustc_version ( 1 , 41 ) ;
6+
47 // Required for stabilization of `unsafe_op_in_unsafe_fn` lint.
58 ac. emit_rustc_version ( 1 , 52 ) ;
69
Original file line number Diff line number Diff line change @@ -1667,13 +1667,22 @@ impl<T: Ord> From<Vec<T>> for BinaryHeap<T> {
16671667 }
16681668}
16691669
1670- // #[stable(feature = "binary_heap_extras_15", since = "1.5.0")]
1671- // impl<T, C: Compare<T>> From<BinaryHeap<T, C>> for Vec<T> {
1672- // fn from(heap: BinaryHeap<T, C>) -> Vec<T> {
1673- // heap.data
1674- // }
1675- // }
1670+ /// # Compatibility
1671+ ///
1672+ /// This trait is only implemented for Rust 1.41.0 or greater. For earlier versions, `Into<Vec<T>>`
1673+ /// is implemented for `BinaryHeap<T, C>` instead.
1674+ #[ cfg( rustc_1_41) ]
1675+ impl < T , C : Compare < T > > From < BinaryHeap < T , C > > for Vec < T > {
1676+ /// Converts a `BinaryHeap<T>` into a `Vec<T>`.
1677+ ///
1678+ /// This conversion requires no data movement or allocation, and has
1679+ /// constant time complexity.
1680+ fn from ( heap : BinaryHeap < T , C > ) -> Vec < T > {
1681+ heap. data
1682+ }
1683+ }
16761684
1685+ #[ cfg( not( rustc_1_41) ) ]
16771686impl < T , C : Compare < T > > Into < Vec < T > > for BinaryHeap < T , C > {
16781687 /// Converts a `BinaryHeap<T>` into a `Vec<T>`.
16791688 ///
You can’t perform that action at this time.
0 commit comments