Skip to content

Commit 3543b7e

Browse files
authored
Merge pull request #1035 from petertseng/unwrapor
decimal: Use unwrap_or; use ? instead of try_opt
2 parents 9ad579f + 021a11f commit 3543b7e

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

exercises/decimal/Cargo-example.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ name = "decimal"
44
version = "0.1.0"
55

66
[dependencies]
7-
try_opt = "0.1.1"
87
num-bigint = "0.1.40"
98
num-traits = "0.1.40"

exercises/decimal/example.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ use std::cmp::Ordering;
22
use std::fmt;
33
use std::ops::{Add, Mul, Sub};
44

5-
#[macro_use]
6-
extern crate try_opt;
7-
85
extern crate num_bigint;
96
use num_bigint::BigInt;
107
extern crate num_traits;
@@ -55,11 +52,8 @@ impl Decimal {
5552
}
5653
}
5754
Some(Decimal::new(
58-
try_opt!(digits.parse::<BigInt>().ok()),
59-
match decimal_index {
60-
Some(idx) => idx,
61-
None => 0,
62-
},
55+
digits.parse().ok()?,
56+
decimal_index.unwrap_or_default(),
6357
))
6458
}
6559

0 commit comments

Comments
 (0)