@@ -1013,11 +1013,14 @@ impl<T, const NS: usize, const ND: usize> TryFrom<[T; NS]> for Deque<T, ND> {
10131013 ///
10141014 /// assert_eq!(deq1, deq2);
10151015 /// ```
1016- type Error = CapacityError ;
1016+ type Error = ( CapacityError , [ T ; NS ] ) ;
10171017
1018+ /// Converts a `[T; NS]` array into a `Deque<T, ND>`.
1019+ ///
1020+ /// Returns back the `value` if NS > ND.
10181021 fn try_from ( value : [ T ; NS ] ) -> Result < Self , Self :: Error > {
10191022 if NS > ND {
1020- return Err ( CapacityError ) ;
1023+ return Err ( ( CapacityError , value ) ) ;
10211024 }
10221025
10231026 let mut deq = Self :: default ( ) ;
@@ -1592,7 +1595,7 @@ mod tests {
15921595 // Array is too big error.
15931596 assert ! ( matches!(
15941597 Deque :: <u8 , 3 >:: try_from( [ 1 , 2 , 3 , 4 ] ) ,
1595- Err ( CapacityError )
1598+ Err ( ( CapacityError , [ 1 , 2 , 3 , 4 ] ) )
15961599 ) ) ;
15971600
15981601 // Array is at limit.
@@ -1645,14 +1648,14 @@ mod tests {
16451648
16461649 // Array is at limit.
16471650 {
1648- let _deq = Deque :: < Droppable , 3 > :: try_from ( [ Droppable :: new ( ) , Droppable :: new ( ) , Droppable :: new ( ) ] ) . unwrap ( ) ;
1651+ let _result = Deque :: < Droppable , 3 > :: try_from ( [ Droppable :: new ( ) , Droppable :: new ( ) , Droppable :: new ( ) ] ) ;
16491652 }
16501653
16511654 assert_eq ! ( Droppable :: count( ) , 0 ) ;
16521655
16531656 // Array is under limit.
16541657 {
1655- let _deq = Deque :: < Droppable , 4 > :: try_from ( [ Droppable :: new ( ) , Droppable :: new ( ) , Droppable :: new ( ) ] ) . unwrap ( ) ;
1658+ let _result = Deque :: < Droppable , 4 > :: try_from ( [ Droppable :: new ( ) , Droppable :: new ( ) , Droppable :: new ( ) ] ) ;
16561659 }
16571660
16581661 assert_eq ! ( Droppable :: count( ) , 0 ) ;
0 commit comments