fn round_to_precision(digits: &mut String, precision: usize) {
        if digits.len() > precision {
            let to_round = digits.split_off(precision);
            let mut digit = digits.pop().unwrap() as u8;

            for c in to_round.chars() {
                match c {
                    c if c < '4' => break,
                    c if c > '4' => {
                        digit += 1;
                        break;
                    }
                    _ => {}
                }
            }

            digits.push(digit as char);
        } else {
            digits.push_str(&"0".repeat(precision - digits.len()));
        }
    }
/// round_to_precision - used in to_precision
///
/// This procedure has two roles:
/// - If there are enough or more than enough digits in the
///   string to show the required precision, the number
///   represented by these digits is rounded using string
///   manipulation.
/// - Else, zeroes are appended to the string.
///
/// When this procedure returns, `digits` is exactly `precision` long.
///
used in to_precision
This procedure has two roles:
If there are enough or more than enough digits in the
string to show the required precision, the number
represented by these digits is rounded using string
manipulation.
Else, zeroes are appended to the string.

When this procedure returns, `digits` is exactly `precision` long.
used in to_precision This procedure has two roles : If there are enough or more than enough digits in the string to show the required precision the number represented by these digits is rounded using string manipulation . Else zeroes are appended to the string . When this procedure returns ` digits ` is exactly ` precision ` long .
fn round_to_precision(digits: &mut String, precision: usize) {
        if digits.len() > precision {
            let to_round = digits.split_off(precision);
            let mut digit = digits.pop().unwrap() as u8;
            for c in to_round.chars() {
                match c {
                    c if c < '4' => break,
                    c if c > '4' => {
                        digit += 1;
                        break;
                    }
                    _ => {}
                }
            }
            digits.push(digit as char);
        } else {
            digits.push_str(&"0".repeat(precision - digits.len()));
        }
    }
fn round_to_precision ( digits : & mut String , precision : usize ) { if digits . len ( ) > precision { let to_round = digits . split_off ( precision ) ; let mut digit = digits . pop ( ) . unwrap ( ) as u8 ; for c in to_round . chars ( ) { match c { c if c < '4' => break , c if c > '4' => { digit += 1 ; break ; } _ => { } } } digits . push ( digit as char ) ; } else { digits . push_str ( & " " . repeat ( precision - digits . len ( ) ) ) ; } }
round_to_precision - used in to_precision
This procedure has two roles:
 If there are enough or more than enough digits in the
string to show the required precision, the number
represented by these digits is rounded using string
manipulation.
round_to_precision - used in to_precision This procedure has two roles : If there are enough or more than enough digits in the string to show the required precision the number represented by these digits is rounded using string manipulation .
digits
&mut String
precision
usize