diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-12-18 15:27:41 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-01-02 12:06:59 -0500 |
| commit | 1b3734f8ae01a07ee3104775976b34cbb281795f (patch) | |
| tree | 1743fc7e68e620738da0f263cc2d297a2f7b57c6 /src/libstd | |
| parent | 1f887c8c5773307033fd821a5045cdc10b790ea5 (diff) | |
| download | rust-1b3734f8ae01a07ee3104775976b34cbb281795f.tar.gz rust-1b3734f8ae01a07ee3104775976b34cbb281795f.zip | |
Fix fallout from change, adding explicit `Sized` annotations where necessary.
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 e8b852ee492..cc8a67249d4 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::{BitOr, BitXor, BitAnd, Sub, Not, 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 FormatWriter 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::FormatWriter for Adaptor<'a, T> { + fn write(&mut self, bytes: &[u8]) -> fmt::Result { + match self.inner.write(bytes) { + Ok(()) => Ok(()), + Err(e) => { + self.error = Err(e); + Err(fmt::Error) + } + } + } + } + + #[cfg(stage0)] impl<'a, T: Writer> fmt::FormatWriter for Adaptor<'a, T> { fn write(&mut self, bytes: &[u8]) -> fmt::Result { match self.inner.write(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`. /// |
