diff options
| author | Palmer Cox <p@lmercox.com> | 2014-01-14 22:32:24 -0500 |
|---|---|---|
| committer | Palmer Cox <p@lmercox.com> | 2014-01-18 01:15:15 -0500 |
| commit | 3fd8c8b3306ae33bdc85811aa410ba01967922bc (patch) | |
| tree | 36818b3c2f6f3c6ba8e145f4a1098dcb87f5bb44 /src/libstd/io | |
| parent | c58d2bacb78ed0d2b9c0c0909e56f390b525aabd (diff) | |
| download | rust-3fd8c8b3306ae33bdc85811aa410ba01967922bc.tar.gz rust-3fd8c8b3306ae33bdc85811aa410ba01967922bc.zip | |
Rename iterators for consistency
Rename existing iterators to get rid of the Iterator suffix and to give them names that better describe the things being iterated over.
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/extensions.rs | 12 | ||||
| -rw-r--r-- | src/libstd/io/fs.rs | 8 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 22 |
3 files changed, 21 insertions, 21 deletions
diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index cc0cb6b3446..511462f89f8 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -24,7 +24,7 @@ use vec::{OwnedVector, ImmutableVector}; /// /// # Notes about the Iteration Protocol /// -/// The `ByteIterator` may yield `None` and thus terminate +/// The `Bytes` may yield `None` and thus terminate /// an iteration, but continue to yield elements if iteration /// is attempted again. /// @@ -33,17 +33,17 @@ use vec::{OwnedVector, ImmutableVector}; /// Raises the same conditions as the `read` method, for /// each call to its `.next()` method. /// Yields `None` if the condition is handled. -pub struct ByteIterator<'r, T> { +pub struct Bytes<'r, T> { priv reader: &'r mut T, } -impl<'r, R: Reader> ByteIterator<'r, R> { - pub fn new(r: &'r mut R) -> ByteIterator<'r, R> { - ByteIterator { reader: r } +impl<'r, R: Reader> Bytes<'r, R> { + pub fn new(r: &'r mut R) -> Bytes<'r, R> { + Bytes { reader: r } } } -impl<'r, R: Reader> Iterator<u8> for ByteIterator<'r, R> { +impl<'r, R: Reader> Iterator<u8> for Bytes<'r, R> { #[inline] fn next(&mut self) -> Option<u8> { self.reader.read_byte() diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index a3f84fe2afa..aac565f2c45 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -508,16 +508,16 @@ pub fn readdir(path: &Path) -> ~[Path] { /// Returns an iterator which will recursively walk the directory structure /// rooted at `path`. The path given will not be iterated over, and this will /// perform iteration in a top-down order. -pub fn walk_dir(path: &Path) -> WalkIterator { - WalkIterator { stack: readdir(path) } +pub fn walk_dir(path: &Path) -> Directories { + Directories { stack: readdir(path) } } /// An iterator which walks over a directory -pub struct WalkIterator { +pub struct Directories { priv stack: ~[Path], } -impl Iterator<Path> for WalkIterator { +impl Iterator<Path> for Directories { fn next(&mut self) -> Option<Path> { match self.stack.shift_opt() { Some(path) => { diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 41cce58d9d5..87180980541 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -624,8 +624,8 @@ pub trait Reader { /// Raises the same conditions as the `read` method, for /// each call to its `.next()` method. /// Ends the iteration if the condition is handled. - fn bytes<'r>(&'r mut self) -> extensions::ByteIterator<'r, Self> { - extensions::ByteIterator::new(self) + fn bytes<'r>(&'r mut self) -> extensions::Bytes<'r, Self> { + extensions::Bytes::new(self) } // Byte conversion helpers @@ -1053,7 +1053,7 @@ impl<T: Reader + Writer> Stream for T {} /// /// # Notes about the Iteration Protocol /// -/// The `LineIterator` may yield `None` and thus terminate +/// The `Lines` may yield `None` and thus terminate /// an iteration, but continue to yield elements if iteration /// is attempted again. /// @@ -1062,11 +1062,11 @@ impl<T: Reader + Writer> Stream for T {} /// Raises the same conditions as the `read` method except for `EndOfFile` /// which is swallowed. /// Iteration yields `None` if the condition is handled. -pub struct LineIterator<'r, T> { +pub struct Lines<'r, T> { priv buffer: &'r mut T, } -impl<'r, T: Buffer> Iterator<~str> for LineIterator<'r, T> { +impl<'r, T: Buffer> Iterator<~str> for Lines<'r, T> { fn next(&mut self) -> Option<~str> { self.buffer.read_line() } @@ -1126,8 +1126,8 @@ pub trait Buffer: Reader { /// /// Iterator raises the same conditions as the `read` method /// except for `EndOfFile`. - fn lines<'r>(&'r mut self) -> LineIterator<'r, Self> { - LineIterator { + fn lines<'r>(&'r mut self) -> Lines<'r, Self> { + Lines { buffer: self, } } @@ -1256,8 +1256,8 @@ pub trait Acceptor<T> { fn accept(&mut self) -> Option<T>; /// Create an iterator over incoming connection attempts - fn incoming<'r>(&'r mut self) -> IncomingIterator<'r, Self> { - IncomingIterator { inc: self } + fn incoming<'r>(&'r mut self) -> IncomingConnections<'r, Self> { + IncomingConnections { inc: self } } } @@ -1268,11 +1268,11 @@ pub trait Acceptor<T> { /// 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<'a, A> { +struct IncomingConnections<'a, A> { priv inc: &'a mut A, } -impl<'a, T, A: Acceptor<T>> Iterator<Option<T>> for IncomingIterator<'a, A> { +impl<'a, T, A: Acceptor<T>> Iterator<Option<T>> for IncomingConnections<'a, A> { fn next(&mut self) -> Option<Option<T>> { Some(self.inc.accept()) } |
