Make itoa::write take a W instead of a &mut W
This commit is contained in:
parent
b2445b6d0e
commit
07bd275999
|
@ -9,12 +9,12 @@
|
||||||
use std::{io, mem, ptr, slice};
|
use std::{io, mem, ptr, slice};
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn write<W: io::Write + ?Sized, V: Integer>(wr: &mut W, value: V) -> io::Result<()> {
|
pub fn write<W: io::Write, V: Integer>(wr: W, value: V) -> io::Result<()> {
|
||||||
value.write(wr)
|
value.write(wr)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Integer {
|
pub trait Integer {
|
||||||
fn write<W: io::Write + ?Sized>(self, &mut W) -> io::Result<()>;
|
fn write<W: io::Write>(self, W) -> io::Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEC_DIGITS_LUT: &'static[u8] =
|
const DEC_DIGITS_LUT: &'static[u8] =
|
||||||
|
@ -30,7 +30,7 @@ macro_rules! impl_Integer {
|
||||||
($($t:ident),* as $conv_fn:ident) => ($(
|
($($t:ident),* as $conv_fn:ident) => ($(
|
||||||
impl Integer for $t {
|
impl Integer for $t {
|
||||||
#[allow(unused_comparisons)]
|
#[allow(unused_comparisons)]
|
||||||
fn write<W: io::Write + ?Sized>(self, wr: &mut W) -> io::Result<()> {
|
fn write<W: io::Write>(self, mut wr: W) -> io::Result<()> {
|
||||||
let is_nonnegative = self >= 0;
|
let is_nonnegative = self >= 0;
|
||||||
let mut n = if is_nonnegative {
|
let mut n = if is_nonnegative {
|
||||||
self as $conv_fn
|
self as $conv_fn
|
||||||
|
|
Loading…
Reference in New Issue