From f907fea593e568a4707d6425d7516c0a7779e8b3 Mon Sep 17 00:00:00 2001 From: alireza_sariri Date: Fri, 8 Nov 2024 11:19:38 +0330 Subject: [PATCH] remove unreachable code in coulombs law --- src/electronics/coulombs_law.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/electronics/coulombs_law.rs b/src/electronics/coulombs_law.rs index 0190b797d57..fc8d9d70947 100644 --- a/src/electronics/coulombs_law.rs +++ b/src/electronics/coulombs_law.rs @@ -14,7 +14,6 @@ const COULOMBS_CONSTANT: f64 = 8.9875517923e9; pub enum CoulombsLawError { ExtraZeroArg(String), NegativeDistance(String), - NoneZeroArg(String), } pub fn coulombs_law( force: f64, @@ -51,16 +50,12 @@ pub fn coulombs_law( "charge2: {}", calculate_charge(charge1, force, distance) )); - } else if distance == 0.0 { + } else { return Ok(format!( "distance: {}", calculate_distance(charge_product, force) )); } - - Err(CoulombsLawError::NoneZeroArg(String::from( - "Exactly one argument must be 0", - ))) } fn calculate_distance(charge_product: f64, force: f64) -> f64 { (COULOMBS_CONSTANT * charge_product / force.abs()).sqrt()