Skip to content

Commit

Permalink
Relax lifetime bounds on Reader/Writer impls for trait boxes
Browse files Browse the repository at this point in the history
Cargo needs this to be able to instantiate `TerminfoTerminal<Box<Writer+'a>>`
for 'a other than 'static.
  • Loading branch information
bkoropoff committed Aug 29, 2014
1 parent 2e92c67 commit 3c182e4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/libstd/io/mod.rs
Expand Up @@ -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) }
}
Expand Down Expand Up @@ -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) }
Expand All @@ -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) }
Expand Down

13 comments on commit 3c182e4

@bors
Copy link
Contributor

@bors bors commented on 3c182e4 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at bkoropoff@3c182e4

@bors
Copy link
Contributor

@bors bors commented on 3c182e4 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging bkoropoff/rust/reader-writer-box = 3c182e4 into auto

@bors
Copy link
Contributor

@bors bors commented on 3c182e4 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bkoropoff/rust/reader-writer-box = 3c182e4 merged ok, testing candidate = 7499d2b6

@bors
Copy link
Contributor

@bors bors commented on 3c182e4 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at bkoropoff@3c182e4

@bors
Copy link
Contributor

@bors bors commented on 3c182e4 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging bkoropoff/rust/reader-writer-box = 3c182e4 into auto

@bors
Copy link
Contributor

@bors bors commented on 3c182e4 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bkoropoff/rust/reader-writer-box = 3c182e4 merged ok, testing candidate = 3efeeec0

@bors
Copy link
Contributor

@bors bors commented on 3c182e4 Sep 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 3c182e4 Sep 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at bkoropoff@3c182e4

@bors
Copy link
Contributor

@bors bors commented on 3c182e4 Sep 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging bkoropoff/rust/reader-writer-box = 3c182e4 into auto

@bors
Copy link
Contributor

@bors bors commented on 3c182e4 Sep 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bkoropoff/rust/reader-writer-box = 3c182e4 merged ok, testing candidate = 67b97ab

@bors
Copy link
Contributor

@bors bors commented on 3c182e4 Sep 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 67b97ab

Please sign in to comment.