From e6f44d98c01aa286a7ac4200804d3b848867a121 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 28 Jan 2017 13:42:35 -0800 Subject: [PATCH] Update function signature in readme --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f69b49d..64c43a1 100644 --- a/README.md +++ b/README.md @@ -23,18 +23,26 @@ primitives. ```rust extern crate itoa; +// write to a vector or other io::Write let mut buf = Vec::new(); -itoa::write(&mut buf, 128u64).unwrap(); +itoa::write(&mut buf, 128u64)?; +println!("{:?}", buf); + +// write to a stack buffer +let mut bytes = [b'\0'; 20]; +let n = itoa::write(&mut bytes[..], 128u64)?; +println!("{:?}", &bytes[..n]); ``` The function signature is: ```rust -fn write(writer: &mut W, value: V) -> io::Result<()> +fn write(writer: W, value: V) -> io::Result ``` where `itoa::Integer` is implemented for `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, -`i64`, `u64`, `isize` and `usize`. +`i64`, `u64`, `isize` and `usize`. The return value gives the number of bytes +written. ## Dependency