Skip to content

Commit

Permalink
Used more Self
Browse files Browse the repository at this point in the history
  • Loading branch information
lorinkoz committed Jun 28, 2024
1 parent ed45eea commit 20619e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/money.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl Money {
if let Ok(money) = value.extract::<Self>() {
return Ok(money);
} else if let Ok(decimal) = value.extract::<Decimal>() {
return Ok(Money { amount: decimal });
return Ok(Self { amount: decimal });
}

Err(PyValueError::new_err("Validation error"))
Expand Down
14 changes: 7 additions & 7 deletions src/money_vat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl MoneyWithVAT {
let tax_result = Money::new(tax);

match (net_result, tax_result) {
(Ok(net_money), Ok(tax_money)) => Ok(MoneyWithVAT {
(Ok(net_money), Ok(tax_money)) => Ok(Self {
net: net_money,
tax: tax_money,
}),
Expand Down Expand Up @@ -349,7 +349,7 @@ impl MoneyWithVAT {

if let Some(true_max_net) = max_net {
if let Some(true_max_gross) = max_gross {
Ok(MoneyWithVAT {
Ok(Self {
net: Money {
amount: true_max_net,
},
Expand Down Expand Up @@ -391,7 +391,7 @@ impl MoneyWithVAT {
let fixed_dividend = if let Some(true_dividend) = dividend {
true_dividend.rounded_to_cents()
} else {
MoneyWithVAT {
Self {
net: Money {
amount: Decimal::new(0, 0),
},
Expand All @@ -403,7 +403,7 @@ impl MoneyWithVAT {
let fixed_divisor = if let Some(true_divisor) = divisor {
true_divisor.rounded_to_cents()
} else {
MoneyWithVAT {
Self {
net: Money {
amount: Decimal::new(0, 0),
},
Expand Down Expand Up @@ -439,7 +439,7 @@ impl MoneyWithVAT {
if true_divisor == Decimal::new(0, 0) {
None
} else {
Some(MoneyWithVAT {
Some(Self {
net: Money {
amount: decimal_div(true_dividend.net.amount, true_divisor),
},
Expand Down Expand Up @@ -472,7 +472,7 @@ impl MoneyWithVAT {
}
}

Ok(MoneyWithVAT {
Ok(Self {
net: Money { amount: net_sum },
tax: Money { amount: tax_sum },
})
Expand Down Expand Up @@ -500,7 +500,7 @@ impl MoneyWithVAT {
if !any_value {
Ok(None)
} else {
Ok(Some(MoneyWithVAT {
Ok(Some(Self {
net: Money { amount: net_sum },
tax: Money { amount: tax_sum },
}))
Expand Down

0 comments on commit 20619e3

Please sign in to comment.