This commit is contained in:
2023-04-08 20:40:35 -07:00
parent fb9cc03bb9
commit e9d4ec0b12
4 changed files with 23 additions and 14 deletions

View File

@ -25,9 +25,9 @@ pub struct Quantity {
impl ToString for Quantity {
fn to_string(&self) -> String {
let n = self.v.to_string();
//n.push(' ');
//n.push_str(&u.to_string());
let mut n = self.v.to_string();
n.push(' ');
n.push_str(&self.u.to_string());
n
}
}
@ -130,10 +130,9 @@ impl Quantity {
}
pub fn pow(&self, pwr: Quantity) -> Quantity {
if !self.unitless() { panic!() }
Quantity {
v: self.v.pow(pwr.v),
u: self.u.clone()
u: self.u.pow(2f64)
}
}
}