diff options
| author | Brian Koropoff <bkoropoff@gmail.com> | 2014-08-29 01:13:43 -0700 |
|---|---|---|
| committer | Brian Koropoff <bkoropoff@gmail.com> | 2014-08-29 01:13:43 -0700 |
| commit | 3c182e422611801d9d723f99d328725a8794ca8d (patch) | |
| tree | a401d154b04a1943fee0aed02879a075f31a3f26 | |
| parent | 2e92c67dc0318a52fe42c3c0bca408f76c7feb61 (diff) | |
| download | rust-3c182e422611801d9d723f99d328725a8794ca8d.tar.gz rust-3c182e422611801d9d723f99d328725a8794ca8d.zip | |
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.
| -rw-r--r-- | src/libstd/io/mod.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 38aa58f1c6a..46c7fee57d3 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -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) } |
