# Crate itoa [−] [src]

This crate provides fast functions for printing integer primitives to an `io::Write` or a `fmt::Write`. The implementation comes straight from libcore but avoids the performance penalty of going through `fmt::Formatter`.

See also `dtoa` for printing floating point primitives.

# Performance (lower is better)

# Examples

ⓘ

    use std::{fmt, io};

    fn demo_itoa_write() -> io::Result<()> {
        // Write to a vector or other io::Write.
        let mut buf = Vec::new();
        itoa::write(&mut buf, 128u64)?;
        println!("{:?}", buf);

        // Write to a stack buffer.
        let mut bytes = [0u8; 20];
        let n = itoa::write(&mut bytes[..], 128u64)?;
        println!("{:?}", &bytes[..n]);

        Ok(())
    }

    fn demo_itoa_fmt() -> fmt::Result {
        // Write to a string.
        let mut s = String::new();
        itoa::fmt(&mut s, 128u64)?;
        println!("{}", s);

        Ok(())
    }

## Structs

Buffer | A safe API for formatting integers to text.

## Traits

Integer | An integer that can be formatted by `itoa::write` and `itoa::fmt`.

## Functions

fmt | Write integer to an `fmt::Write`.
write | Write integer to an `io::Write`.