fn combine_factors(factors: &mut Vec<(usize, usize)>, ks: &Vec<(usize, usize)>) {
    // tuples are immutable, so we construct new tuples and remove old. This
    // can result in a potentially unsorted state.
    'outer: for &(f, c) in ks {
        for mut ft in factors.iter_mut() {
            if ft.0 == f {
                *ft = (f, c + ft.1);
                continue 'outer;
            }
        }

        // We did not find the factor, so add it as a new one
        match factors.iter().position(|&(ff, _)| ff > f) {
            Some(idx) => factors.insert(idx, (f, c)),
            None => factors.push((f, c))
        }
    }
}
/// Combine a factor list with another. This is equivalent to multiplying
/// a number x by a number y, but working with their factors directly.
Combine a factor list with another. This is equivalent to multiplying
a number x by a number y, but working with their factors directly.
Combine a factor list with another . This is equivalent to multiplying a number x by a number y but working with their factors directly .
fn combine_factors(factors: &mut Vec<(usize, usize)>, ks: &Vec<(usize, usize)>) {
    // tuples are immutable, so we construct new tuples and remove old. This
    // can result in a potentially unsorted state.
    'outer: for &(f, c) in ks {
        for mut ft in factors.iter_mut() {
            if ft.0 == f {
                *ft = (f, c + ft.1);
                continue 'outer;
            }
        }
        // We did not find the factor, so add it as a new one
        match factors.iter().position(|&(ff, _)| ff > f) {
            Some(idx) => factors.insert(idx, (f, c)),
            None => factors.push((f, c))
        }
    }
}
fn combine_factors ( factors : & mut Vec < ( usize , usize ) > , ks : & Vec < ( usize , usize ) > ) { // tuples are immutable, so we construct new tuples and remove old. This // can result in a potentially unsorted state. ' outer : for & ( f , c ) in ks { for mut ft in factors . iter_mut ( ) { if ft . 0 == f { * ft = ( f , c + ft . 1 ) ; continue ' outer ; } } // We did not find the factor, so add it as a new one match factors . iter ( ) . position ( | & ( ff , _ ) | ff > f ) { Some ( idx ) => factors . insert ( idx , ( f , c ) ) , None => factors . push ( ( f , c ) ) } } }
Combine a factor list with another.
Combine a factor list with another .
factors
&mut Vec<(usize, usize)>
ks
&Vec<(usize, usize)>