pub fn simplify(&mut self) -> Number {
        let mut factor = one();
        if self.units.len() > 1 {
            for i in 1..(self.units.len()) {
                let (a, b) = self.units.split_at_mut(i);
                let (au, ap) = a.last_mut().unwrap();
                for (bu, bp) in b {
                    if let Some(f) = bu.scale_to(au) {
                        if ap.abs() > bp.abs() {
                            factor = factor * f.powi((*bp).into());
                            *ap += *bp;
                            *bp = 0;
                        } else {
                            factor = factor / f.powi((*ap).into());
                            *bp += *ap;
                            *ap = 0;
                        }
                    }
                }
            }
        }
        self.units.retain(|(_u, p)| *p != 0);
        factor
    }
/// Simplify this unit set, returning a scaling factor.
Simplify this unit set, returning a scaling factor.
Simplify this unit set returning a scaling factor .
pub fn simplify(&mut self) -> Number {
        let mut factor = one();
        if self.units.len() > 1 {
            for i in 1..(self.units.len()) {
                let (a, b) = self.units.split_at_mut(i);
                let (au, ap) = a.last_mut().unwrap();
                for (bu, bp) in b {
                    if let Some(f) = bu.scale_to(au) {
                        if ap.abs() > bp.abs() {
                            factor = factor * f.powi((*bp).into());
                            *ap += *bp;
                            *bp = 0;
                        } else {
                            factor = factor / f.powi((*ap).into());
                            *bp += *ap;
                            *ap = 0;
                        }
                    }
                }
            }
        }
        self.units.retain(|(_u, p)| *p != 0);
        factor
    }
pub fn simplify ( & mut self ) -> Number { let mut factor = one ( ) ; if self . units . len ( ) > 1 { for i in 1 .. ( self . units . len ( ) ) { let ( a , b ) = self . units . split_at_mut ( i ) ; let ( au , ap ) = a . last_mut ( ) . unwrap ( ) ; for ( bu , bp ) in b { if let Some ( f ) = bu . scale_to ( au ) { if ap . abs ( ) > bp . abs ( ) { factor = factor * f . powi ( ( * bp ) . into ( ) ) ; * ap += * bp ; * bp = 0 ; } else { factor = factor / f . powi ( ( * ap ) . into ( ) ) ; * bp += * ap ; * ap = 0 ; } } } } } self . units . retain ( | ( _u , p ) | * p != 0 ) ; factor }
Simplify this unit set, returning a scaling factor.
Simplify this unit set returning a scaling factor .
&mut self