1
Fork 0

Replace a few expect+format combos with unwrap_or_else+panic

This commit is contained in:
ljedrz 2018-07-23 14:47:13 +02:00
parent 210d61f05c
commit fe588d894f
5 changed files with 8 additions and 8 deletions

View file

@ -232,11 +232,11 @@ pub mod printf {
impl Num {
fn from_str(s: &str, arg: Option<&str>) -> Self {
if let Some(arg) = arg {
Num::Arg(arg.parse().expect(&format!("invalid format arg `{:?}`", arg)))
Num::Arg(arg.parse().unwrap_or_else(|_| panic!("invalid format arg `{:?}`", arg)))
} else if s == "*" {
Num::Next
} else {
Num::Num(s.parse().expect(&format!("invalid format num `{:?}`", s)))
Num::Num(s.parse().unwrap_or_else(|_| panic!("invalid format num `{:?}`", s)))
}
}