Skip to content

Commit e7d87e9

Browse files
clippy fix
1 parent 2769e8c commit e7d87e9

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

traits/src/currency.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use sp_runtime::{
99
DispatchError, DispatchResult,
1010
};
1111
use sp_std::{
12-
cmp::{Eq, PartialEq},
12+
cmp::{Eq, Ordering, PartialEq},
1313
fmt::Debug,
1414
result,
1515
};
@@ -301,16 +301,17 @@ pub trait NamedMultiReservableCurrency<AccountId>: MultiReservableCurrency<Accou
301301
value: Self::Balance,
302302
) -> DispatchResult {
303303
let current = Self::reserved_balance_named(id, currency_id, who);
304-
if current > value {
305-
// we always have enough balance to unreserve here
306-
Self::unreserve_named(id, currency_id, who, current - value);
307-
Ok(())
308-
} else if value > current {
309-
// we checked value > current
310-
Self::reserve_named(id, currency_id, who, value - current)
311-
} else {
312-
// current == value
313-
Ok(())
304+
match current.cmp(&value) {
305+
Ordering::Less => {
306+
// we checked value > current
307+
Self::reserve_named(id, currency_id, who, value - current)
308+
}
309+
Ordering::Equal => Ok(()),
310+
Ordering::Greater => {
311+
// we always have enough balance to unreserve here
312+
Self::unreserve_named(id, currency_id, who, current - value);
313+
Ok(())
314+
}
314315
}
315316
}
316317

0 commit comments

Comments
 (0)