mirror of https://github.com/rm-dr/daisy
Minor fixes
parent
cb227d9539
commit
f07ba9ed38
|
@ -116,10 +116,10 @@ impl Quantity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_rational_from_string(s: &str) -> Quantity {
|
pub fn new_rational_from_string(s: &str) -> Option<Quantity> {
|
||||||
return Quantity::Rational {
|
let r = RationalQ::from_string(s);
|
||||||
v: RationalQ::from_string(s)
|
if r.is_none() { return None; }
|
||||||
}
|
return Some(Quantity::Rational { v: r.unwrap() });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_rational_from_f64(f: f64) ->
|
pub fn new_rational_from_f64(f: f64) ->
|
||||||
|
|
|
@ -63,9 +63,13 @@ impl RationalQ {
|
||||||
return Some(RationalQ{ val: v.unwrap() });
|
return Some(RationalQ{ val: v.unwrap() });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_string(s: &str) -> RationalQ {
|
pub fn from_string(s: &str) -> Option<RationalQ> {
|
||||||
let v = Rational::from_str_radix(s, 10);
|
let v = Rational::from_str_radix(s, 10);
|
||||||
return RationalQ{ val: v.unwrap() };
|
let v = match v {
|
||||||
|
Ok(x) => x,
|
||||||
|
Err(_) => return None
|
||||||
|
};
|
||||||
|
return Some(RationalQ{ val: v });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_float(&self) -> Float {
|
pub fn to_float(&self) -> Float {
|
||||||
|
|
|
@ -572,7 +572,7 @@ impl Operator{
|
||||||
|
|
||||||
if let Token::Number(v) = args {
|
if let Token::Number(v) = args {
|
||||||
if !v.fract().is_zero() { return Err(()); }
|
if !v.fract().is_zero() { return Err(()); }
|
||||||
if v >= Quantity::new_rational(100, 1) { return Err(()); }
|
if v > Quantity::new_rational(50_000, 1) { return Err(()); }
|
||||||
|
|
||||||
let mut prod = Quantity::new_rational(1, 1);
|
let mut prod = Quantity::new_rational(1, 1);
|
||||||
let mut u = v.clone();
|
let mut u = v.clone();
|
||||||
|
|
Loading…
Reference in New Issue