Skip to content

Commit

Permalink
remove unreachable code in coulombs law
Browse files Browse the repository at this point in the history
  • Loading branch information
alirezasariri78 committed Nov 8, 2024
1 parent 4f862f3 commit f907fea
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/electronics/coulombs_law.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit f907fea

Please sign in to comment.