@@ -163,12 +163,12 @@ impl Price {
163163 . mul ( & discount_interpolated) ?
164164 . scale_to_exponent ( expo_orig) ?;
165165
166- return Some ( Price {
166+ Some ( Price {
167167 price : price_discounted. price ,
168168 conf : conf_orig,
169169 expo : price_discounted. expo ,
170170 publish_time : self . publish_time ,
171- } ) ;
171+ } )
172172 }
173173
174174 /// Get the valuation of a borrow position according to:
@@ -243,12 +243,12 @@ impl Price {
243243 . mul ( & premium_interpolated) ?
244244 . scale_to_exponent ( expo_orig) ?;
245245
246- return Some ( Price {
246+ Some ( Price {
247247 price : price_premium. price ,
248248 conf : conf_orig,
249249 expo : price_premium. expo ,
250250 publish_time : self . publish_time ,
251- } ) ;
251+ } )
252252 }
253253
254254 /// affine_combination performs an affine combination of two prices located at x coordinates x1
@@ -345,7 +345,7 @@ impl Price {
345345 right = right. scale_to_exponent ( pre_add_expo) ?;
346346
347347 // 8. compute H = F + G, Err(H) ~= 4x + 2*10^pre_add_expo
348- return left. add ( & right) ;
348+ left. add ( & right)
349349 }
350350
351351 /// Get the price of a basket of currencies.
@@ -637,15 +637,14 @@ impl Price {
637637 // get the relevant fraction
638638 let frac = x_as_price. div ( & y_as_price) ?;
639639
640- return Some ( frac) ;
640+ Some ( frac)
641641 }
642642}
643643
644644#[ cfg( test) ]
645645mod test {
646646 use quickcheck:: TestResult ;
647647 use quickcheck_macros:: quickcheck;
648- use std:: convert:: TryFrom ;
649648
650649 use crate :: price:: {
651650 Price ,
@@ -2053,12 +2052,12 @@ mod test {
20532052 }
20542053
20552054 pub fn construct_quickcheck_affine_combination_price ( price : i64 ) -> Price {
2056- return Price {
2055+ Price {
20572056 price : price,
20582057 conf : 0 ,
20592058 expo : -9 ,
20602059 publish_time : 0 ,
2061- } ;
2060+ }
20622061 }
20632062
20642063 // quickcheck to confirm affine_combination introduces no error if normalization done
@@ -2078,12 +2077,12 @@ mod test {
20782077 ) -> TestResult {
20792078 // generating xs and prices from i32 to limit the range to reasonable values and guard
20802079 // against overflow/bespoke constraint setting for quickcheck
2081- let y1 = construct_quickcheck_affine_combination_price ( i64:: try_from ( p1) . ok ( ) . unwrap ( ) ) ;
2082- let y2 = construct_quickcheck_affine_combination_price ( i64:: try_from ( p2) . ok ( ) . unwrap ( ) ) ;
2080+ let y1 = construct_quickcheck_affine_combination_price ( i64:: from ( p1) ) ;
2081+ let y2 = construct_quickcheck_affine_combination_price ( i64:: from ( p2) ) ;
20832082
2084- let x1 = i64:: try_from ( x1_inp) . ok ( ) . unwrap ( ) ;
2085- let x2 = i64:: try_from ( x2_inp) . ok ( ) . unwrap ( ) ;
2086- let x_query = i64:: try_from ( x_query_inp) . ok ( ) . unwrap ( ) ;
2083+ let x1 = i64:: from ( x1_inp) ;
2084+ let x2 = i64:: from ( x2_inp) ;
2085+ let x_query = i64:: from ( x_query_inp) ;
20872086
20882087 // stick with single expo for ease of testing and generation
20892088 let pre_add_expo = -9 ;
@@ -2124,12 +2123,12 @@ mod test {
21242123 ) -> TestResult {
21252124 // generating xs and prices from i32 to limit the range to reasonable values and guard
21262125 // against overflow/bespoke constraint setting for quickcheck
2127- let y1 = construct_quickcheck_affine_combination_price ( i64:: try_from ( p1) . ok ( ) . unwrap ( ) ) ;
2128- let y2 = construct_quickcheck_affine_combination_price ( i64:: try_from ( p2) . ok ( ) . unwrap ( ) ) ;
2126+ let y1 = construct_quickcheck_affine_combination_price ( i64:: from ( p1) ) ;
2127+ let y2 = construct_quickcheck_affine_combination_price ( i64:: from ( p2) ) ;
21292128
2130- let x1 = i64:: try_from ( x1_inp) . ok ( ) . unwrap ( ) ;
2131- let x2 = i64:: try_from ( x2_inp) . ok ( ) . unwrap ( ) ;
2132- let x_query = i64:: try_from ( x_query_inp) . ok ( ) . unwrap ( ) ;
2129+ let x1 = i64:: from ( x1_inp) ;
2130+ let x2 = i64:: from ( x2_inp) ;
2131+ let x_query = i64:: from ( x_query_inp) ;
21332132
21342133 // stick with single expo for ease of testing and generation
21352134 let pre_add_expo = -9 ;
@@ -2159,7 +2158,7 @@ mod test {
21592158
21602159 x1_new = 0 ;
21612160 xq_new = frac_q2. price ;
2162- x2_new = 100_000_000 as i64 ;
2161+ x2_new = 100_000_000 ;
21632162 }
21642163
21652164 // original result
0 commit comments