Update function signature in readme

This commit is contained in:
David Tolnay 2017-01-28 13:42:35 -08:00
parent 036a5d8e12
commit e6f44d98c0
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
1 changed files with 11 additions and 3 deletions

View File

@ -23,18 +23,26 @@ primitives.
```rust ```rust
extern crate itoa; extern crate itoa;
// write to a vector or other io::Write
let mut buf = Vec::new(); 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: The function signature is:
```rust ```rust
fn write<W: io::Write + ?Sized, V: itoa::Integer>(writer: &mut W, value: V) -> io::Result<()> fn write<W: io::Write, V: itoa::Integer>(writer: W, value: V) -> io::Result<usize>
``` ```
where `itoa::Integer` is implemented for `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, 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 ## Dependency