Accept references to trait objects

This commit is contained in:
David Tolnay 2017-01-23 16:45:03 -08:00
parent 2ddc75cab4
commit 97dad04178
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
1 changed files with 3 additions and 3 deletions

View File

@ -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] =
@ -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