mirror of https://github.com/rm-dr/daisy
Cleaned up a few panic!()s
parent
8fef5702b4
commit
be043af4f0
|
@ -145,7 +145,7 @@ pub fn do_command(
|
|||
t = format!("{}{}", color::Fg(color::Magenta), style::Bold)
|
||||
)?;
|
||||
},
|
||||
_ => panic!("Bad command!")
|
||||
_ => unreachable!("Bad command!")
|
||||
};
|
||||
|
||||
return Ok(());
|
||||
|
|
|
@ -89,7 +89,7 @@ fn do_expression(
|
|||
|
||||
} else {
|
||||
match g {
|
||||
Ok(_) => panic!(),
|
||||
Ok(_) => unreachable!(),
|
||||
|
||||
Err(EvalError::TooBig) => {
|
||||
write!(
|
||||
|
|
|
@ -54,6 +54,6 @@ pub fn eval_function(f: &Function, args: &VecDeque<Expression>) -> Result<Expres
|
|||
|
||||
Function::ToBase
|
||||
| Function::NoUnit
|
||||
=> panic!()
|
||||
=> unreachable!()
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ fn push_token(g: &mut VecDeque<Token>, t: Option<Token>, stop_i: usize) {
|
|||
|
||||
Token::Group(_,_)
|
||||
| Token::Container(_)
|
||||
=> panic!()
|
||||
=> unreachable!()
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ impl Token {
|
|||
| Token::GroupStart(_)
|
||||
| Token::GroupEnd(_)
|
||||
| Token::Group(_, _)
|
||||
=> panic!()
|
||||
=> panic!("This token cannot be converted to an expression")
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ impl Add for Quantity {
|
|||
type Output = Self;
|
||||
|
||||
fn add(self, other: Self) -> Self::Output {
|
||||
if !self.unit.compatible_with(&other.unit) { panic!() }
|
||||
if !self.unit.compatible_with(&other.unit) { panic!("Tried to add incompatible units") }
|
||||
|
||||
let mut o = other;
|
||||
if self.unit != o.unit {
|
||||
|
@ -271,7 +271,7 @@ impl Add for Quantity {
|
|||
|
||||
impl AddAssign for Quantity where {
|
||||
fn add_assign(&mut self, other: Self) {
|
||||
if !self.unit.compatible_with(&other.unit) { panic!() }
|
||||
if !self.unit.compatible_with(&other.unit) { panic!("Tried to addassign incompatible units") }
|
||||
|
||||
let mut o = other;
|
||||
if self.unit != o.unit {
|
||||
|
@ -286,7 +286,7 @@ impl Sub for Quantity {
|
|||
type Output = Self;
|
||||
|
||||
fn sub(self, other: Self) -> Self::Output {
|
||||
if !self.unit.compatible_with(&other.unit) { panic!() }
|
||||
if !self.unit.compatible_with(&other.unit) { panic!("Tried to subtract incompatible units") }
|
||||
|
||||
let mut o = other;
|
||||
if self.unit != o.unit {
|
||||
|
@ -302,7 +302,7 @@ impl Sub for Quantity {
|
|||
|
||||
impl SubAssign for Quantity where {
|
||||
fn sub_assign(&mut self, other: Self) {
|
||||
if !self.unit.compatible_with(&other.unit) { panic!() }
|
||||
if !self.unit.compatible_with(&other.unit) { panic!("Tried to subassign incompatible units") }
|
||||
|
||||
let mut o = other;
|
||||
if self.unit != o.unit {
|
||||
|
@ -369,8 +369,8 @@ impl Rem<Quantity> for Quantity {
|
|||
type Output = Self;
|
||||
|
||||
fn rem(self, other: Quantity) -> Self::Output {
|
||||
if !self.unit.unitless() { panic!() }
|
||||
if !other.unit.unitless() { panic!() }
|
||||
if !self.unit.unitless() { panic!("Tried to % a quantity with units") }
|
||||
if !other.unit.unitless() { panic!("Tried to % by a quantity with units") }
|
||||
|
||||
Quantity {
|
||||
scalar: self.scalar % other.scalar,
|
||||
|
@ -389,7 +389,7 @@ impl PartialEq for Quantity {
|
|||
|
||||
impl PartialOrd for Quantity {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
if self.unit != other.unit { panic!() }
|
||||
if self.unit != other.unit { panic!("Tried to compare incompatible units") }
|
||||
self.scalar.partial_cmp(&other.scalar)
|
||||
}
|
||||
}
|
|
@ -52,7 +52,7 @@ impl ToString for Unit {
|
|||
'7' => '⁷',
|
||||
'8' => '⁸',
|
||||
'9' => '⁹',
|
||||
_ => panic!()
|
||||
_ => unreachable!()
|
||||
});
|
||||
}
|
||||
t.push('·');
|
||||
|
@ -90,7 +90,7 @@ impl ToString for Unit {
|
|||
'7' => '⁷',
|
||||
'8' => '⁸',
|
||||
'9' => '⁹',
|
||||
_ => panic!()
|
||||
_ => unreachable!()
|
||||
});
|
||||
}
|
||||
b.push('·');
|
||||
|
|
Loading…
Reference in New Issue