Skip to content

Commit 021a11f

Browse files
decimal: use ? instead of try_opt
Since 1.22, have been able to use ? for Option. https://doc.rust-lang.org/edition-guide/rust-2018/error-handling-and-panics/the-question-mark-operator-for-easier-error-handling.html Co-authored-by: Peter Goodspeed-Niklaus <[email protected]>
1 parent c0cd239 commit 021a11f

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
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: 1 addition & 4 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,7 +52,7 @@ impl Decimal {
5552
}
5653
}
5754
Some(Decimal::new(
58-
try_opt!(digits.parse::<BigInt>().ok()),
55+
digits.parse().ok()?,
5956
decimal_index.unwrap_or_default(),
6057
))
6158
}

0 commit comments

Comments
 (0)