Skip to content

Commit

Permalink
Inline the itoa::write calls
Browse files Browse the repository at this point in the history
Inlining this simple, already `core`-compatible function is better than
noisily repeating the same definition that does exactly the same, albeit
hidden behind a fn call.
  • Loading branch information
Xanewok committed Jan 20, 2020
1 parent 23e5ef5 commit 1f586cd
Showing 1 changed file with 0 additions and 88 deletions.
88 changes: 0 additions & 88 deletions src/ser.rs
Expand Up @@ -1634,17 +1634,6 @@ pub trait Formatter {

/// Writes an integer value like `-123` to the specified writer.
#[inline]
#[cfg(feature = "std")]
fn write_i8<W: ?Sized>(&mut self, writer: &mut W, value: i8) -> io::Result<()>
where
W: io::Write,
{
itoa::write(writer, value).map(drop)
}

/// Writes an integer value like `-123` to the specified writer.
#[inline]
#[cfg(not(feature = "std"))]
fn write_i8<W: ?Sized>(&mut self, writer: &mut W, value: i8) -> io::Result<()>
where
W: io::Write,
Expand All @@ -1656,17 +1645,6 @@ pub trait Formatter {

/// Writes an integer value like `-123` to the specified writer.
#[inline]
#[cfg(feature = "std")]
fn write_i16<W: ?Sized>(&mut self, writer: &mut W, value: i16) -> io::Result<()>
where
W: io::Write,
{
itoa::write(writer, value).map(drop)
}

/// Writes an integer value like `-123` to the specified writer.
#[inline]
#[cfg(not(feature = "std"))]
fn write_i16<W: ?Sized>(&mut self, writer: &mut W, value: i16) -> io::Result<()>
where
W: io::Write,
Expand All @@ -1678,17 +1656,6 @@ pub trait Formatter {

/// Writes an integer value like `-123` to the specified writer.
#[inline]
#[cfg(feature = "std")]
fn write_i32<W: ?Sized>(&mut self, writer: &mut W, value: i32) -> io::Result<()>
where
W: io::Write,
{
itoa::write(writer, value).map(drop)
}

/// Writes an integer value like `-123` to the specified writer.
#[inline]
#[cfg(not(feature = "std"))]
fn write_i32<W: ?Sized>(&mut self, writer: &mut W, value: i32) -> io::Result<()>
where
W: io::Write,
Expand All @@ -1700,17 +1667,6 @@ pub trait Formatter {

/// Writes an integer value like `-123` to the specified writer.
#[inline]
#[cfg(feature = "std")]
fn write_i64<W: ?Sized>(&mut self, writer: &mut W, value: i64) -> io::Result<()>
where
W: io::Write,
{
itoa::write(writer, value).map(drop)
}

/// Writes an integer value like `-123` to the specified writer.
#[inline]
#[cfg(not(feature = "std"))]
fn write_i64<W: ?Sized>(&mut self, writer: &mut W, value: i64) -> io::Result<()>
where
W: io::Write,
Expand All @@ -1722,17 +1678,6 @@ pub trait Formatter {

/// Writes an integer value like `123` to the specified writer.
#[inline]
#[cfg(feature = "std")]
fn write_u8<W: ?Sized>(&mut self, writer: &mut W, value: u8) -> io::Result<()>
where
W: io::Write,
{
itoa::write(writer, value).map(drop)
}

/// Writes an integer value like `123` to the specified writer.
#[inline]
#[cfg(not(feature = "std"))]
fn write_u8<W: ?Sized>(&mut self, writer: &mut W, value: u8) -> io::Result<()>
where
W: io::Write,
Expand All @@ -1744,17 +1689,6 @@ pub trait Formatter {

/// Writes an integer value like `123` to the specified writer.
#[inline]
#[cfg(feature = "std")]
fn write_u16<W: ?Sized>(&mut self, writer: &mut W, value: u16) -> io::Result<()>
where
W: io::Write,
{
itoa::write(writer, value).map(drop)
}

/// Writes an integer value like `123` to the specified writer.
#[inline]
#[cfg(not(feature = "std"))]
fn write_u16<W: ?Sized>(&mut self, writer: &mut W, value: u16) -> io::Result<()>
where
W: io::Write,
Expand All @@ -1766,17 +1700,6 @@ pub trait Formatter {

/// Writes an integer value like `123` to the specified writer.
#[inline]
#[cfg(feature = "std")]
fn write_u32<W: ?Sized>(&mut self, writer: &mut W, value: u32) -> io::Result<()>
where
W: io::Write,
{
itoa::write(writer, value).map(drop)
}

/// Writes an integer value like `123` to the specified writer.
#[inline]
#[cfg(not(feature = "std"))]
fn write_u32<W: ?Sized>(&mut self, writer: &mut W, value: u32) -> io::Result<()>
where
W: io::Write,
Expand All @@ -1788,17 +1711,6 @@ pub trait Formatter {

/// Writes an integer value like `123` to the specified writer.
#[inline]
#[cfg(feature = "std")]
fn write_u64<W: ?Sized>(&mut self, writer: &mut W, value: u64) -> io::Result<()>
where
W: io::Write,
{
itoa::write(writer, value).map(drop)
}

/// Writes an integer value like `123` to the specified writer.
#[inline]
#[cfg(not(feature = "std"))]
fn write_u64<W: ?Sized>(&mut self, writer: &mut W, value: u64) -> io::Result<()>
where
W: io::Write,
Expand Down

0 comments on commit 1f586cd

Please sign in to comment.