diff --git a/src/branch.rs b/src/branch.rs index 8197415d1b..681f1c5327 100644 --- a/src/branch.rs +++ b/src/branch.rs @@ -113,7 +113,8 @@ impl<'repo> Branches<'repo> { } } -impl<'repo> Iterator<(Branch<'repo>, BranchType)> for Branches<'repo> { +impl<'repo> Iterator for Branches<'repo> { + type Item = (Branch<'repo>, BranchType); fn next(&mut self) -> Option<(Branch<'repo>, BranchType)> { let mut ret = 0 as *mut raw::git_reference; let mut typ = raw::GIT_BRANCH_LOCAL; diff --git a/src/commit.rs b/src/commit.rs index 32bdaeddf6..804acda999 100644 --- a/src/commit.rs +++ b/src/commit.rs @@ -246,35 +246,37 @@ impl<'repo> Commit<'repo> { } } -impl<'repo, 'commit> Iterator> for Parents<'commit, 'repo> { +impl<'repo, 'commit> Iterator for Parents<'commit, 'repo> { + type Item = Commit<'repo>; fn next(&mut self) -> Option> { self.range.next().map(|i| self.commit.parent(i).unwrap()) } fn size_hint(&self) -> (uint, Option) { self.range.size_hint() } } -impl<'repo, 'commit> DoubleEndedIterator> for Parents<'commit, 'repo> { +impl<'repo, 'commit> DoubleEndedIterator for Parents<'commit, 'repo> { fn next_back(&mut self) -> Option> { self.range.next_back().map(|i| self.commit.parent(i).unwrap()) } } -impl<'repo, 'commit> ExactSizeIterator> for Parents<'commit, 'repo> {} +impl<'repo, 'commit> ExactSizeIterator for Parents<'commit, 'repo> {} -impl<'commit> Iterator for ParentIds<'commit> { +impl<'commit> Iterator for ParentIds<'commit> { + type Item = Oid; fn next(&mut self) -> Option { self.range.next().map(|i| self.commit.parent_id(i).unwrap()) } fn size_hint(&self) -> (uint, Option) { self.range.size_hint() } } -impl<'commit> DoubleEndedIterator for ParentIds<'commit> { +impl<'commit> DoubleEndedIterator for ParentIds<'commit> { fn next_back(&mut self) -> Option { self.range.next_back().map(|i| self.commit.parent_id(i).unwrap()) } } -impl<'commit> ExactSizeIterator for ParentIds<'commit> {} +impl<'commit> ExactSizeIterator for ParentIds<'commit> {} #[unsafe_destructor] impl<'repo> Drop for Commit<'repo> { diff --git a/src/config.rs b/src/config.rs index c4460b1a9e..2dac25b8eb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -386,7 +386,8 @@ impl<'cfg> ConfigEntries<'cfg> { // // It's also not implemented for `&'b mut T` so we can have multiple entries // (ok). -impl<'cfg, 'b> Iterator> for &'b ConfigEntries<'cfg> { +impl<'cfg, 'b> Iterator for &'b ConfigEntries<'cfg> { + type Item = ConfigEntry<'b>; fn next(&mut self) -> Option> { let mut raw = 0 as *mut raw::git_config_entry; unsafe { diff --git a/src/diff.rs b/src/diff.rs index dcedd501c9..f1688c9f5d 100644 --- a/src/diff.rs +++ b/src/diff.rs @@ -647,18 +647,19 @@ impl DiffOptions { // TODO: expose ignore_submodules, notify_cb/notify_payload } -impl<'diff> Iterator> for Deltas<'diff> { +impl<'diff> Iterator for Deltas<'diff> { + type Item = DiffDelta<'diff>; fn next(&mut self) -> Option> { self.range.next().and_then(|i| self.diff.get_delta(i)) } fn size_hint(&self) -> (uint, Option) { self.range.size_hint() } } -impl<'diff> DoubleEndedIterator> for Deltas<'diff> { +impl<'diff> DoubleEndedIterator for Deltas<'diff> { fn next_back(&mut self) -> Option> { self.range.next_back().and_then(|i| self.diff.get_delta(i)) } } -impl<'diff> ExactSizeIterator> for Deltas<'diff> {} +impl<'diff> ExactSizeIterator for Deltas<'diff> {} impl<'a> DiffLine<'a> { /// Create a new diff line from its raw component. diff --git a/src/index.rs b/src/index.rs index 51d28da75a..ced59989b5 100644 --- a/src/index.rs +++ b/src/index.rs @@ -420,7 +420,8 @@ impl Drop for Index { } } -impl<'index> Iterator for IndexEntries<'index> { +impl<'index> Iterator for IndexEntries<'index> { + type Item = IndexEntry; fn next(&mut self) -> Option { self.range.next().map(|i| self.index.get(i).unwrap()) } diff --git a/src/lib.rs b/src/lib.rs index 12a64c39f7..9d9957018a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,6 +64,7 @@ //! itself. #![feature(macro_rules, unsafe_destructor, unboxed_closures)] +#![feature(associated_types)] #![deny(missing_docs)] #![cfg_attr(test, deny(warnings))] diff --git a/src/note.rs b/src/note.rs index 9fe29496ce..2b2e72fc3e 100644 --- a/src/note.rs +++ b/src/note.rs @@ -79,7 +79,8 @@ impl<'repo> Notes<'repo> { } } -impl<'repo> Iterator<(Oid, Oid)> for Notes<'repo> { +impl<'repo> Iterator for Notes<'repo> { + type Item = (Oid, Oid); fn next(&mut self) -> Option<(Oid, Oid)> { let mut note_id = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; let mut annotated_id = note_id; diff --git a/src/pathspec.rs b/src/pathspec.rs index abfe40d745..be6844b386 100644 --- a/src/pathspec.rs +++ b/src/pathspec.rs @@ -38,7 +38,7 @@ pub struct PathspecFailedEntries<'list> { impl Pathspec { /// Creates a new pathspec from a list of specs to match against. pub fn new(specs: I) -> Result - where T: ToCStr, I: Iterator { + where T: ToCStr, I: Iterator { let strs = specs.map(|s| s.to_c_str()).collect::>(); let ptrs = strs.iter().map(|c| c.as_ptr()).collect::>(); let arr = raw::git_strarray { @@ -222,44 +222,47 @@ impl<'ps> Drop for PathspecMatchList<'ps> { } } -impl<'list> Iterator<&'list [u8]> for PathspecEntries<'list> { +impl<'list> Iterator for PathspecEntries<'list> { + type Item = &'list [u8]; fn next(&mut self) -> Option<&'list [u8]> { self.range.next().and_then(|i| self.list.entry(i)) } fn size_hint(&self) -> (uint, Option) { self.range.size_hint() } } -impl<'list> DoubleEndedIterator<&'list [u8]> for PathspecEntries<'list> { +impl<'list> DoubleEndedIterator for PathspecEntries<'list> { fn next_back(&mut self) -> Option<&'list [u8]> { self.range.next_back().and_then(|i| self.list.entry(i)) } } -impl<'list> ExactSizeIterator<&'list [u8]> for PathspecEntries<'list> {} +impl<'list> ExactSizeIterator for PathspecEntries<'list> {} -impl<'list> Iterator> for PathspecDiffEntries<'list> { +impl<'list> Iterator for PathspecDiffEntries<'list> { + type Item = DiffDelta<'list>; fn next(&mut self) -> Option> { self.range.next().and_then(|i| self.list.diff_entry(i)) } fn size_hint(&self) -> (uint, Option) { self.range.size_hint() } } -impl<'list> DoubleEndedIterator> for PathspecDiffEntries<'list> { +impl<'list> DoubleEndedIterator for PathspecDiffEntries<'list> { fn next_back(&mut self) -> Option> { self.range.next_back().and_then(|i| self.list.diff_entry(i)) } } -impl<'list> ExactSizeIterator> for PathspecDiffEntries<'list> {} +impl<'list> ExactSizeIterator for PathspecDiffEntries<'list> {} -impl<'list> Iterator<&'list [u8]> for PathspecFailedEntries<'list> { +impl<'list> Iterator for PathspecFailedEntries<'list> { + type Item = &'list [u8]; fn next(&mut self) -> Option<&'list [u8]> { self.range.next().and_then(|i| self.list.failed_entry(i)) } fn size_hint(&self) -> (uint, Option) { self.range.size_hint() } } -impl<'list> DoubleEndedIterator<&'list [u8]> for PathspecFailedEntries<'list> { +impl<'list> DoubleEndedIterator for PathspecFailedEntries<'list> { fn next_back(&mut self) -> Option<&'list [u8]> { self.range.next_back().and_then(|i| self.list.failed_entry(i)) } } -impl<'list> ExactSizeIterator<&'list [u8]> for PathspecFailedEntries<'list> {} +impl<'list> ExactSizeIterator for PathspecFailedEntries<'list> {} #[cfg(test)] mod tests { diff --git a/src/reference.rs b/src/reference.rs index 2b3fe2ac49..2d38ed1c8c 100644 --- a/src/reference.rs +++ b/src/reference.rs @@ -226,7 +226,8 @@ impl<'repo> References<'repo> { } } -impl<'repo> Iterator> for References<'repo> { +impl<'repo> Iterator for References<'repo> { + type Item = Reference<'repo>; fn next(&mut self) -> Option> { let mut out = 0 as *mut raw::git_reference; if unsafe { raw::git_reference_next(&mut out, self.raw) == 0 } { @@ -257,7 +258,8 @@ impl<'repo> ReferenceNames<'repo> { } } -impl<'repo> Iterator<&'repo str> for ReferenceNames<'repo> { +impl<'repo> Iterator for ReferenceNames<'repo> { + type Item = &'repo str; fn next(&mut self) -> Option<&'repo str> { let mut out = 0 as *const libc::c_char; if unsafe { raw::git_reference_next_name(&mut out, self.inner.raw) == 0 } { diff --git a/src/remote.rs b/src/remote.rs index 5c9f18d382..5e9bbc231b 100644 --- a/src/remote.rs +++ b/src/remote.rs @@ -168,8 +168,8 @@ impl<'repo, 'cb> Remote<'repo, 'cb> { } /// Set the remote's list of fetch refspecs - pub fn set_fetch_refspecs>(&mut self, i: I) - -> Result<(), Error> { + pub fn set_fetch_refspecs>(&mut self, i: I) + -> Result<(), Error> { let v = i.map(|t| t.to_c_str()).collect::>(); let v2 = v.iter().map(|v| v.as_ptr()).collect::>(); let mut arr = raw::git_strarray { @@ -184,8 +184,8 @@ impl<'repo, 'cb> Remote<'repo, 'cb> { } /// Set the remote's list of push refspecs - pub fn set_push_refspecs>(&mut self, i: I) - -> Result<(), Error> { + pub fn set_push_refspecs>(&mut self, i: I) + -> Result<(), Error> { let v = i.map(|t| t.to_c_str()).collect::>(); let v2 = v.iter().map(|v| v.as_ptr()).collect::>(); let mut arr = raw::git_strarray { @@ -329,7 +329,8 @@ impl<'repo, 'cb> Remote<'repo, 'cb> { } } -impl<'a, 'b> Iterator> for Refspecs<'a, 'b> { +impl<'a, 'b> Iterator for Refspecs<'a, 'b> { + type Item = Refspec<'a>; fn next(&mut self) -> Option> { if self.cur == self.cnt { return None } let ret = unsafe { diff --git a/src/repo.rs b/src/repo.rs index 9b2020eeea..341f4b2020 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -359,9 +359,9 @@ impl Repository { /// matching the provided pathspecs. pub fn reset_default<'a, T: ToCStr, - I: Iterator>(&'a self, - target: Option<&Object<'a>>, - paths: I) -> Result<(), Error> { + I: Iterator>(&'a self, + target: Option<&Object<'a>>, + paths: I) -> Result<(), Error> { let v = paths.map(|t| t.to_c_str()).collect::>(); let v2 = v.iter().map(|v| v.as_ptr()).collect::>(); let mut arr = raw::git_strarray { diff --git a/src/revwalk.rs b/src/revwalk.rs index 211be5bb78..338d399b00 100644 --- a/src/revwalk.rs +++ b/src/revwalk.rs @@ -160,7 +160,8 @@ impl<'repo> Drop for Revwalk<'repo> { } } -impl<'repo> Iterator for Revwalk<'repo> { +impl<'repo> Iterator for Revwalk<'repo> { + type Item = Oid; fn next(&mut self) -> Option { let mut out: raw::git_oid = raw::git_oid{ id: [0; raw::GIT_OID_RAWSZ] }; unsafe { diff --git a/src/status.rs b/src/status.rs index 789c466ea1..3ccee1e024 100644 --- a/src/status.rs +++ b/src/status.rs @@ -279,20 +279,21 @@ impl<'repo> Drop for Statuses<'repo> { } } -impl<'a> Iterator> for StatusIter<'a> { +impl<'a> Iterator for StatusIter<'a> { + type Item = StatusEntry<'a>; fn next(&mut self) -> Option> { self.range.next().and_then(|i| self.statuses.get(i)) } fn size_hint(&self) -> (uint, Option) { self.range.size_hint() } } -impl<'a> DoubleEndedIterator> for StatusIter<'a> { +impl<'a> DoubleEndedIterator for StatusIter<'a> { fn next_back(&mut self) -> Option> { self.range.next_back().and_then(|i| self.statuses.get(i)) } } -impl<'a> ExactSizeIterator> for StatusIter<'a> {} +impl<'a> ExactSizeIterator for StatusIter<'a> {} impl<'statuses> StatusEntry<'statuses> { /// Create a new status entry from its raw component. diff --git a/src/string_array.rs b/src/string_array.rs index 793aa19544..47b3d3b156 100644 --- a/src/string_array.rs +++ b/src/string_array.rs @@ -68,7 +68,8 @@ impl StringArray { pub fn len(&self) -> uint { self.raw.count as uint } } -impl<'a> Iterator> for StringArrayItems<'a> { +impl<'a> Iterator for StringArrayItems<'a> { + type Item = Option<&'a str>; fn next(&mut self) -> Option> { if self.cur < self.arr.len() { self.cur += 1; @@ -79,7 +80,8 @@ impl<'a> Iterator> for StringArrayItems<'a> { } } -impl<'a> Iterator<&'a [u8]> for StringArrayBytes<'a> { +impl<'a> Iterator for StringArrayBytes<'a> { + type Item = &'a [u8]; fn next(&mut self) -> Option<&'a [u8]> { if self.cur < self.arr.len() { self.cur += 1;