mirror of
https://github.com/rm-dr/daisy
synced 2025-07-05 10:09:33 -07:00
Cleanup
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,10 +58,12 @@ impl Unit {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn pow(&mut self, pwr: f64) {
|
||||
for (_, p) in &mut self.val {
|
||||
pub fn pow(&self, pwr: f64) -> Unit {
|
||||
let mut u = self.clone();
|
||||
for (_, p) in &mut u.val {
|
||||
*p *= pwr;
|
||||
}
|
||||
};
|
||||
return u;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user