Relax lifetime bounds on Reader/Writer impls for trait boxes

Cargo needs this to be able to instantiate `TerminfoTerminal<Box<Writer+'a>>`
for 'a other than 'static.
This commit is contained in:
Brian Koropoff 2014-08-29 01:13:43 -07:00
parent 2e92c67dc0
commit 3c182e4226

View File

@ -945,10 +945,16 @@ pub trait Reader {
}
}
#[cfg(stage0)]
impl Reader for Box<Reader+'static> {
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.read(buf) }
}
#[cfg(not(stage0))]
impl<'a> Reader for Box<Reader+'a> {
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.read(buf) }
}
impl<'a> Reader for &'a mut Reader+'a {
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.read(buf) }
}
@ -1295,6 +1301,7 @@ pub trait Writer {
}
}
#[cfg(stage0)]
impl Writer for Box<Writer+'static> {
#[inline]
fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.write(buf) }
@ -1303,6 +1310,15 @@ impl Writer for Box<Writer+'static> {
fn flush(&mut self) -> IoResult<()> { self.flush() }
}
#[cfg(not(stage0))]
impl<'a> Writer for Box<Writer+'a> {
#[inline]
fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.write(buf) }
#[inline]
fn flush(&mut self) -> IoResult<()> { self.flush() }
}
impl<'a> Writer for &'a mut Writer+'a {
#[inline]
fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.write(buf) }