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 1
1
fn main ( ) {
2
2
let ac = autocfg:: new ( ) ;
3
3
4
+ // Required in order to implement `From<BinaryHeap<T, C>>` for `Vec<T>`.
5
+ ac. emit_rustc_version ( 1 , 41 ) ;
6
+
4
7
// Required for stabilization of `unsafe_op_in_unsafe_fn` lint.
5
8
ac. emit_rustc_version ( 1 , 52 ) ;
6
9
Original file line number Diff line number Diff line change @@ -1667,13 +1667,22 @@ impl<T: Ord> From<Vec<T>> for BinaryHeap<T> {
1667
1667
}
1668
1668
}
1669
1669
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
+ }
1676
1684
1685
+ #[ cfg( not( rustc_1_41) ) ]
1677
1686
impl < T , C : Compare < T > > Into < Vec < T > > for BinaryHeap < T , C > {
1678
1687
/// Converts a `BinaryHeap<T>` into a `Vec<T>`.
1679
1688
///
You can’t perform that action at this time.
0 commit comments