@@ -163,12 +163,12 @@ impl Price {
163
163
. mul ( & discount_interpolated) ?
164
164
. scale_to_exponent ( expo_orig) ?;
165
165
166
- return Some ( Price {
166
+ Some ( Price {
167
167
price : price_discounted. price ,
168
168
conf : conf_orig,
169
169
expo : price_discounted. expo ,
170
170
publish_time : self . publish_time ,
171
- } ) ;
171
+ } )
172
172
}
173
173
174
174
/// Get the valuation of a borrow position according to:
@@ -243,12 +243,12 @@ impl Price {
243
243
. mul ( & premium_interpolated) ?
244
244
. scale_to_exponent ( expo_orig) ?;
245
245
246
- return Some ( Price {
246
+ Some ( Price {
247
247
price : price_premium. price ,
248
248
conf : conf_orig,
249
249
expo : price_premium. expo ,
250
250
publish_time : self . publish_time ,
251
- } ) ;
251
+ } )
252
252
}
253
253
254
254
/// affine_combination performs an affine combination of two prices located at x coordinates x1
@@ -345,7 +345,7 @@ impl Price {
345
345
right = right. scale_to_exponent ( pre_add_expo) ?;
346
346
347
347
// 8. compute H = F + G, Err(H) ~= 4x + 2*10^pre_add_expo
348
- return left. add ( & right) ;
348
+ left. add ( & right)
349
349
}
350
350
351
351
/// Get the price of a basket of currencies.
@@ -637,15 +637,14 @@ impl Price {
637
637
// get the relevant fraction
638
638
let frac = x_as_price. div ( & y_as_price) ?;
639
639
640
- return Some ( frac) ;
640
+ Some ( frac)
641
641
}
642
642
}
643
643
644
644
#[ cfg( test) ]
645
645
mod test {
646
646
use quickcheck:: TestResult ;
647
647
use quickcheck_macros:: quickcheck;
648
- use std:: convert:: TryFrom ;
649
648
650
649
use crate :: price:: {
651
650
Price ,
@@ -2053,12 +2052,12 @@ mod test {
2053
2052
}
2054
2053
2055
2054
pub fn construct_quickcheck_affine_combination_price ( price : i64 ) -> Price {
2056
- return Price {
2055
+ Price {
2057
2056
price : price,
2058
2057
conf : 0 ,
2059
2058
expo : -9 ,
2060
2059
publish_time : 0 ,
2061
- } ;
2060
+ }
2062
2061
}
2063
2062
2064
2063
// quickcheck to confirm affine_combination introduces no error if normalization done
@@ -2078,12 +2077,12 @@ mod test {
2078
2077
) -> TestResult {
2079
2078
// generating xs and prices from i32 to limit the range to reasonable values and guard
2080
2079
// 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) ) ;
2083
2082
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) ;
2087
2086
2088
2087
// stick with single expo for ease of testing and generation
2089
2088
let pre_add_expo = -9 ;
@@ -2124,12 +2123,12 @@ mod test {
2124
2123
) -> TestResult {
2125
2124
// generating xs and prices from i32 to limit the range to reasonable values and guard
2126
2125
// 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) ) ;
2129
2128
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) ;
2133
2132
2134
2133
// stick with single expo for ease of testing and generation
2135
2134
let pre_add_expo = -9 ;
@@ -2159,7 +2158,7 @@ mod test {
2159
2158
2160
2159
x1_new = 0 ;
2161
2160
xq_new = frac_q2. price ;
2162
- x2_new = 100_000_000 as i64 ;
2161
+ x2_new = 100_000_000 ;
2163
2162
}
2164
2163
2165
2164
// original result
0 commit comments