Skip to content

Commit b38be35

Browse files
use fmt and clippy
1 parent b9919e5 commit b38be35

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/financial/present_value.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ pub fn present_value(discount_rate: f64, cash_flows: Vec<f64>) -> Result<f64, Pr
2121
Ok(round(present_value))
2222
}
2323

24-
fn round(value:f64)->f64{
25-
( value * 100.0).round() / 100.0
24+
fn round(value: f64) -> f64 {
25+
(value * 100.0).round() / 100.0
2626
}
2727

28-
2928
#[cfg(test)]
3029
mod tests {
3130
use super::*;
@@ -66,24 +65,22 @@ mod tests {
6665
}
6766
}
6867

69-
70-
test_present_value!{
68+
test_present_value! {
7169
general_inputs1:((0.13, vec![10.0, 20.70, -293.0, 297.0]),4.69),
7270
general_inputs2:((0.07, vec![-109129.39, 30923.23, 15098.93, 29734.0, 39.0]),-42739.63),
7371
general_inputs3:((0.07, vec![109129.39, 30923.23, 15098.93, 29734.0, 39.0]), 175519.15),
7472
zero_input:((0.0, vec![109129.39, 30923.23, 15098.93, 29734.0, 39.0]), 184924.55),
7573

7674
}
7775

78-
test_present_value_Err!{
76+
test_present_value_Err! {
7977
negative_discount_rate:((-1.0, vec![10.0, 20.70, -293.0, 297.0]), PresentValueError::NegetiveDiscount),
8078
empty_cash_flow:((1.0, vec![]), PresentValueError::EmptyCashFlow),
8179

8280
}
83-
test_round!{
81+
test_round! {
8482
test1:(0.55434, 0.55),
8583
test2:(10.453, 10.45),
8684
test3:(1111_f64, 1111_f64),
8785
}
8886
}
89-

0 commit comments

Comments
 (0)