Skip to content

Commit

Permalink
Accept references to trait objects
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 24, 2017
1 parent 2ddc75c commit 97dad04
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
use std::{io, mem, ptr, slice};

#[inline]
pub fn write<W: io::Write, V: Integer>(wr: &mut W, value: V) -> io::Result<()> {
pub fn write<W: io::Write + ?Sized, V: Integer>(wr: &mut W, value: V) -> io::Result<()> {
value.write(wr)
}

pub trait Integer {
fn write<W: io::Write>(self, &mut W) -> io::Result<()>;
fn write<W: io::Write + ?Sized>(self, &mut W) -> io::Result<()>;
}

const DEC_DIGITS_LUT: &'static[u8] =
Expand All @@ -30,7 +30,7 @@ macro_rules! impl_Integer {
($($t:ident),* as $conv_fn:ident) => ($(
impl Integer for $t {
#[allow(unused_comparisons)]
fn write<W: io::Write>(self, wr: &mut W) -> io::Result<()> {
fn write<W: io::Write + ?Sized>(self, wr: &mut W) -> io::Result<()> {
let is_nonnegative = self >= 0;
let mut n = if is_nonnegative {
self as $conv_fn
Expand Down

0 comments on commit 97dad04

Please sign in to comment.