diff --git a/src/libstd/rt/io/mod.rs b/src/libstd/rt/io/mod.rs index 5ceea877453..37c53de09e6 100644 --- a/src/libstd/rt/io/mod.rs +++ b/src/libstd/rt/io/mod.rs @@ -493,7 +493,7 @@ pub trait Acceptor { /// then `accept` returns `None`. fn accept(&mut self) -> Option; - /// Create an iterator over incoming connections + /// Create an iterator over incoming connection attempts fn incoming<'r>(&'r mut self) -> IncomingIterator<'r, Self> { IncomingIterator { inc: self } } @@ -501,13 +501,18 @@ pub trait Acceptor { /// An infinite iterator over incoming connection attempts. /// Calling `next` will block the task until a connection is attempted. +/// +/// Since connection attempts can continue forever, this iterator always returns Some. +/// The Some contains another Option representing whether the connection attempt was succesful. +/// A successful connection will be wrapped in Some. +/// A failed connection is represented as a None and raises a condition. struct IncomingIterator<'self, A> { priv inc: &'self mut A, } -impl<'self, T, A: Acceptor> Iterator for IncomingIterator<'self, A> { - fn next(&mut self) -> Option { - self.inc.accept() +impl<'self, T, A: Acceptor> Iterator> for IncomingIterator<'self, A> { + fn next(&mut self) -> Option> { + Some(self.inc.accept()) } }