diff options
author | Edwin Cheng <[email protected]> | 2019-04-25 19:56:44 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-04-25 19:56:44 +0100 |
commit | 1908819bf6432016527f4bd3b0f22500b85cab5f (patch) | |
tree | f48081403383b7a00a3c297b2ff24a7c11ddd07e /crates | |
parent | c55a2dbc1de8ba42df57b70f652eb6a0c0bbc9f6 (diff) |
Use panic instead of unwrap
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_mbe/src/subtree_source.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs index 845020f4e..6255ea304 100644 --- a/crates/ra_mbe/src/subtree_source.rs +++ b/crates/ra_mbe/src/subtree_source.rs | |||
@@ -438,14 +438,12 @@ fn convert_delim(d: tt::Delimiter, closing: bool) -> TtToken { | |||
438 | } | 438 | } |
439 | 439 | ||
440 | fn convert_literal(l: &tt::Literal) -> TtToken { | 440 | fn convert_literal(l: &tt::Literal) -> TtToken { |
441 | let kind = classify_literal(&l.text) | 441 | let kind = |
442 | .map(|tkn| tkn.kind) | 442 | classify_literal(&l.text).map(|tkn| tkn.kind).unwrap_or_else(|| match l.text.as_ref() { |
443 | .or_else(|| match l.text.as_ref() { | 443 | "true" => SyntaxKind::TRUE_KW, |
444 | "true" => Some(SyntaxKind::TRUE_KW), | 444 | "false" => SyntaxKind::FALSE_KW, |
445 | "false" => Some(SyntaxKind::FALSE_KW), | 445 | _ => panic!("Fail to convert given literal {:#?}", &l), |
446 | _ => None, | 446 | }); |
447 | }) | ||
448 | .unwrap(); | ||
449 | 447 | ||
450 | TtToken { kind, is_joint_to_next: false, text: l.text.clone(), n_tokens: 1 } | 448 | TtToken { kind, is_joint_to_next: false, text: l.text.clone(), n_tokens: 1 } |
451 | } | 449 | } |