Skip to content

Commit 1908819

Browse files
committed
Use panic instead of unwrap
1 parent c55a2db commit 1908819

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

crates/ra_mbe/src/subtree_source.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -438,14 +438,12 @@ fn convert_delim(d: tt::Delimiter, closing: bool) -> TtToken {
438438
}
439439

440440
fn convert_literal(l: &tt::Literal) -> TtToken {
441-
let kind = classify_literal(&l.text)
442-
.map(|tkn| tkn.kind)
443-
.or_else(|| match l.text.as_ref() {
444-
"true" => Some(SyntaxKind::TRUE_KW),
445-
"false" => Some(SyntaxKind::FALSE_KW),
446-
_ => None,
447-
})
448-
.unwrap();
441+
let kind =
442+
classify_literal(&l.text).map(|tkn| tkn.kind).unwrap_or_else(|| match l.text.as_ref() {
443+
"true" => SyntaxKind::TRUE_KW,
444+
"false" => SyntaxKind::FALSE_KW,
445+
_ => panic!("Fail to convert given literal {:#?}", &l),
446+
});
449447

450448
TtToken { kind, is_joint_to_next: false, text: l.text.clone(), n_tokens: 1 }
451449
}

0 commit comments

Comments
 (0)