fn write_num(&mut self, num: f64, precision: Precision) -> usize {
        let mut tmp = dtoa::Buffer::new();
        let s = tmp.format(num);
        let tmp = s.as_bytes();
        let n = tmp.len();
        let mut digits = 0;
        let mut written = 0;
        let mut in_frac = false;
        let mut thou = 2 - (num.abs().log10().trunc() as u8) % 3;
        let mut idx = self.start;

        for i in 0..n {
            let byte = tmp[i]; // obtain byte
            self.strbuf[idx] = byte; // write byte
            idx += 1;
            written += 1; // increment counter

            if byte.is_ascii_digit() {
                digits += 1;
                thou += 1;
            }

            // look ahead otherwise it would include the decimal always even for 0 precision
            if i + 1 < n && tmp[i + 1] == b'.' {
                in_frac = true;
                if let Decimals(_) = precision {
                    digits = 0
                }
            }

            if !in_frac && thou == 3 {
                if let Some(sep) = self.thou_sep {
                    thou = 0;
                    self.strbuf[idx] = sep;
                    idx += 1;
                    written += 1;
                }
            }

            match precision {
                Significance(d) | Decimals(d) if in_frac => {
                    if digits >= d {
                        break;
                    }
                }
                _ => (),
            }
        }

        written
    }
/// Writes `num` into the string buffer with the specified `precision`.
/// Returns the number of bytes written.
/// Injects the thousands separator into the integer portion if it exists.
Writes `num` into the string buffer with the specified `precision`.
Returns the number of bytes written.
Injects the thousands separator into the integer portion if it exists.
Writes ` num ` into the string buffer with the specified ` precision ` . Returns the number of bytes written . Injects the thousands separator into the integer portion if it exists .
fn write_num(&mut self, num: f64, precision: Precision) -> usize {
        let mut tmp = dtoa::Buffer::new();
        let s = tmp.format(num);
        let tmp = s.as_bytes();
        let n = tmp.len();
        let mut digits = 0;
        let mut written = 0;
        let mut in_frac = false;
        let mut thou = 2 - (num.abs().log10().trunc() as u8) % 3;
        let mut idx = self.start;
        for i in 0..n {
            let byte = tmp[i]; // obtain byte
            self.strbuf[idx] = byte; // write byte
            idx += 1;
            written += 1; // increment counter
            if byte.is_ascii_digit() {
                digits += 1;
                thou += 1;
            }
            // look ahead otherwise it would include the decimal always even for 0 precision
            if i + 1 < n && tmp[i + 1] == b'.' {
                in_frac = true;
                if let Decimals(_) = precision {
                    digits = 0
                }
            }
            if !in_frac && thou == 3 {
                if let Some(sep) = self.thou_sep {
                    thou = 0;
                    self.strbuf[idx] = sep;
                    idx += 1;
                    written += 1;
                }
            }
            match precision {
                Significance(d) | Decimals(d) if in_frac => {
                    if digits >= d {
                        break;
                    }
                }
                _ => (),
            }
        }
        written
    }
fn write_num ( & mut self , num : f64 , precision : Precision ) -> usize { let mut tmp = dtoa :: Buffer :: new ( ) ; let s = tmp . format ( num ) ; let tmp = s . as_bytes ( ) ; let n = tmp . len ( ) ; let mut digits = 0 ; let mut written = 0 ; let mut in_frac = false ; let mut thou = 2 - ( num . abs ( ) . log10 ( ) . trunc ( ) as u8 ) % 3 ; let mut idx = self . start ; for i in 0 .. n { let byte = tmp [ i ] ; // obtain byte self . strbuf [ idx ] = byte ; // write byte idx += 1 ; written += 1 ; // increment counter if byte . is_ascii_digit ( ) { digits += 1 ; thou += 1 ; } // look ahead otherwise it would include the decimal always even for 0 precision if i + 1 < n && tmp [ i + 1 ] == b'.' { in_frac = true ; if let Decimals ( _ ) = precision { digits = 0 } } if ! in_frac && thou == 3 { if let Some ( sep ) = self . thou_sep { thou = 0 ; self . strbuf [ idx ] = sep ; idx += 1 ; written += 1 ; } } match precision { Significance ( d ) | Decimals ( d ) if in_frac => { if digits >= d { break ; } } _ => ( ) , } } written }
Writes `num` into the string buffer with the specified `precision`.
Writes ` num ` into the string buffer with the specified ` precision ` .
&mut self
num
f64
precision
Precision
&mut self
num
f64
precision
Precision