fn parse_cpu(s: &str) -> Result<f64> {
    let digits = s
        .chars()
        .take_while(|ch| ch.is_digit(10) || *ch == '.')
        .collect::<String>();
    let unit = s
        .chars()
        .skip_while(|ch| ch.is_digit(10) || *ch == '.')
        .collect::<String>();
    let mut res: f64 = digits.parse()?;

    trace!("Parsed {} ({})", digits, unit);
    if unit == "m" {
        res /= 1000.0;
    } else if unit == "k" {
        res *= 1000.0;
    } else if unit != "" {
        bail!("Unknown unit {}", unit);
    }
    trace!("Returned {} cores", res);
    Ok(res)
}
// Parse normal k8s cpu resource values into floats
// We don't allow power of two variants here
Parse normal k8s cpu resource values into floats
We don't allow power of two variants here
Parse normal k8s cpu resource values into floats We don ' t allow power of two variants here
fn parse_cpu(s: &str) -> Result<f64> {
    let digits = s
        .chars()
        .take_while(|ch| ch.is_digit(10) || *ch == '.')
        .collect::<String>();
    let unit = s
        .chars()
        .skip_while(|ch| ch.is_digit(10) || *ch == '.')
        .collect::<String>();
    let mut res: f64 = digits.parse()?;
    trace!("Parsed {} ({})", digits, unit);
    if unit == "m" {
        res /= 1000.0;
    } else if unit == "k" {
        res *= 1000.0;
    } else if unit != "" {
        bail!("Unknown unit {}", unit);
    }
    trace!("Returned {} cores", res);
    Ok(res)
}
fn parse_cpu ( s : & str ) -> Result < f64 > { let digits = s . chars ( ) . take_while ( | ch | ch . is_digit ( 10 ) || * ch == '.' ) . collect :: < String > ( ) ; let unit = s . chars ( ) . skip_while ( | ch | ch . is_digit ( 10 ) || * ch == '.' ) . collect :: < String > ( ) ; let mut res : f64 = digits . parse ( ) ? ; trace ! ( " " digits unit ) ; if unit == " " { res /= 1000.0 ; } else if unit == " " { res *= 1000.0 ; } else if unit != " " { bail ! ( " " unit ) ; } trace ! ( " " res ) ; Ok ( res ) }
Parse normal k8s cpu resource values into floats
We don't allow power of two variants here
Parse normal k8s cpu resource values into floats We don ' t allow power of two variants here
s
&str
s
&str