From 15ac4ec45c28500a583d2f05d2b1322a55e8d8e2 Mon Sep 17 00:00:00 2001 From: Bauke Date: Fri, 8 Apr 2022 22:54:17 +0200 Subject: [PATCH] Replace unreachable panics with unreachable!(). --- source/roman_to_integer/mod.rs | 2 +- source/two_sum/mod.rs | 2 +- source/valid_parenthesis/mod.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/roman_to_integer/mod.rs b/source/roman_to_integer/mod.rs index 4bb74ca..3af6140 100644 --- a/source/roman_to_integer/mod.rs +++ b/source/roman_to_integer/mod.rs @@ -11,7 +11,7 @@ pub fn roman_to_int(string: String) -> i32 { 'C' => 100, 'D' => 500, 'M' => 1000, - _ => panic!("Unknown character: {character}"), + _ => unreachable!(), }; if let Some(next) = characters.peek() { diff --git a/source/two_sum/mod.rs b/source/two_sum/mod.rs index ba9441a..3db3e1c 100644 --- a/source/two_sum/mod.rs +++ b/source/two_sum/mod.rs @@ -13,5 +13,5 @@ pub fn two_sum(numbers: Vec, target: i32) -> Vec { } } - panic!("No pair of numbers found that sum to {}", target) + unreachable!() } diff --git a/source/valid_parenthesis/mod.rs b/source/valid_parenthesis/mod.rs index d53c04e..e351ac2 100644 --- a/source/valid_parenthesis/mod.rs +++ b/source/valid_parenthesis/mod.rs @@ -10,7 +10,7 @@ pub fn is_valid(string: String) -> bool { '[' => ']', '{' => '}', '(' => ')', - _ => panic!("Invalid input character: {character}"), + _ => unreachable!(), } }