diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-01-02 10:58:10 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-02 11:13:05 -0800 |
| commit | 4459b1dcedc5b0cb195c2494beda56b87105a980 (patch) | |
| tree | 8de1b3e206541d31e6697aa5466e9fabff223cbd /src/libstd | |
| parent | e921e3f04513ffb094208a538a2835d4dc77b991 (diff) | |
| parent | 704ed4c7d00d256b783086a682fbcfd7a4ac5c5a (diff) | |
| download | rust-4459b1dcedc5b0cb195c2494beda56b87105a980.tar.gz rust-4459b1dcedc5b0cb195c2494beda56b87105a980.zip | |
rollup merge of #20341: nikomatsakis/impl-trait-for-trait-2
Conflicts: src/librustc/middle/traits/mod.rs src/libstd/io/mod.rs src/test/run-pass/builtin-superkinds-self-type.rs
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/mod.rs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 539fcb23bb0..8f7de1c4dca 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -232,6 +232,7 @@ use error::{FromError, Error}; use fmt; use int; use iter::{Iterator, IteratorExt}; +use kinds::Sized; use mem::transmute; use ops::FnOnce; use option::Option; @@ -1030,11 +1031,25 @@ pub trait Writer { fn write_fmt(&mut self, fmt: fmt::Arguments) -> IoResult<()> { // Create a shim which translates a Writer to a fmt::Writer and saves // off I/O errors. instead of discarding them - struct Adaptor<'a, T:'a> { + struct Adaptor<'a, Sized? T:'a> { inner: &'a mut T, error: IoResult<()>, } + #[cfg(not(stage0))] + impl<'a, Sized? T: Writer> fmt::Writer for Adaptor<'a, T> { + fn write_str(&mut self, s: &str) -> fmt::Result { + match self.inner.write(s.as_bytes()) { + Ok(()) => Ok(()), + Err(e) => { + self.error = Err(e); + Err(fmt::Error) + } + } + } + } + + #[cfg(stage0)] impl<'a, T: Writer> fmt::Writer for Adaptor<'a, T> { fn write_str(&mut self, s: &str) -> fmt::Result { match self.inner.write(s.as_bytes()) { @@ -1629,16 +1644,24 @@ pub trait Acceptor<T> { /// `Some`. The `Some` contains the `IoResult` representing whether the /// connection attempt was successful. A successful connection will be wrapped /// in `Ok`. A failed connection is represented as an `Err`. -pub struct IncomingConnections<'a, A:'a> { +pub struct IncomingConnections<'a, Sized? A:'a> { inc: &'a mut A, } +#[cfg(stage0)] impl<'a, T, A: Acceptor<T>> Iterator<IoResult<T>> for IncomingConnections<'a, A> { fn next(&mut self) -> Option<IoResult<T>> { Some(self.inc.accept()) } } +#[cfg(not(stage0))] +impl<'a, T, Sized? A: Acceptor<T>> Iterator<IoResult<T>> for IncomingConnections<'a, A> { + fn next(&mut self) -> Option<IoResult<T>> { + Some(self.inc.accept()) + } +} + /// Creates a standard error for a commonly used flavor of error. The `detail` /// field of the returned error will always be `None`. /// |
