Skip to content

Commit 7f21181

Browse files
authored
Merge pull request #955 from vallentin/fused
Implemented FusedIterator for various iterators
2 parents 414dede + f0d52d3 commit 7f21181

10 files changed

+31
-1
lines changed

Diff for: src/blame.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::util::{self, Binding};
22
use crate::{raw, signature, Oid, Repository, Signature};
3+
use std::iter::FusedIterator;
34
use std::marker;
45
use std::mem;
56
use std::ops::Range;
@@ -307,6 +308,8 @@ impl<'blame> DoubleEndedIterator for BlameIter<'blame> {
307308
}
308309
}
309310

311+
impl<'blame> FusedIterator for BlameIter<'blame> {}
312+
310313
impl<'blame> ExactSizeIterator for BlameIter<'blame> {}
311314

312315
#[cfg(test)]

Diff for: src/commit.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use libc;
2+
use std::iter::FusedIterator;
23
use std::marker;
34
use std::mem;
45
use std::ops::Range;
@@ -376,6 +377,8 @@ impl<'repo, 'commit> DoubleEndedIterator for Parents<'commit, 'repo> {
376377
}
377378
}
378379

380+
impl<'repo, 'commit> FusedIterator for Parents<'commit, 'repo> {}
381+
379382
impl<'repo, 'commit> ExactSizeIterator for Parents<'commit, 'repo> {}
380383

381384
/// Aborts iteration when a commit cannot be found
@@ -400,6 +403,8 @@ impl<'commit> DoubleEndedIterator for ParentIds<'commit> {
400403
}
401404
}
402405

406+
impl<'commit> FusedIterator for ParentIds<'commit> {}
407+
403408
impl<'commit> ExactSizeIterator for ParentIds<'commit> {}
404409

405410
impl<'repo> Clone for Commit<'repo> {

Diff for: src/diff.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use libc::{c_char, c_int, c_void, size_t};
22
use std::ffi::CString;
3+
use std::iter::FusedIterator;
34
use std::marker;
45
use std::mem;
56
use std::ops::Range;
@@ -959,6 +960,8 @@ impl<'diff> DoubleEndedIterator for Deltas<'diff> {
959960
self.range.next_back().and_then(|i| self.diff.get_delta(i))
960961
}
961962
}
963+
impl<'diff> FusedIterator for Deltas<'diff> {}
964+
962965
impl<'diff> ExactSizeIterator for Deltas<'diff> {}
963966

964967
/// Line origin constants.

Diff for: src/message.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use core::ops::Range;
22
use std::ffi::CStr;
33
use std::ffi::CString;
4+
use std::iter::FusedIterator;
45
use std::ptr;
56

67
use libc::{c_char, c_int};
@@ -171,6 +172,8 @@ impl<'pair> Iterator for MessageTrailersStrsIterator<'pair> {
171172
}
172173
}
173174

175+
impl FusedIterator for MessageTrailersStrsIterator<'_> {}
176+
174177
impl ExactSizeIterator for MessageTrailersStrsIterator<'_> {
175178
fn len(&self) -> usize {
176179
self.0.range.len()
@@ -213,6 +216,8 @@ impl<'pair> Iterator for MessageTrailersBytesIterator<'pair> {
213216
}
214217
}
215218

219+
impl FusedIterator for MessageTrailersBytesIterator<'_> {}
220+
216221
impl ExactSizeIterator for MessageTrailersBytesIterator<'_> {
217222
fn len(&self) -> usize {
218223
self.0.range.len()

Diff for: src/pathspec.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use libc::size_t;
2-
use std::iter::IntoIterator;
2+
use std::iter::{FusedIterator, IntoIterator};
33
use std::marker;
44
use std::ops::Range;
55
use std::path::Path;
@@ -297,6 +297,7 @@ impl<'list> DoubleEndedIterator for PathspecEntries<'list> {
297297
self.range.next_back().and_then(|i| self.list.entry(i))
298298
}
299299
}
300+
impl<'list> FusedIterator for PathspecEntries<'list> {}
300301
impl<'list> ExactSizeIterator for PathspecEntries<'list> {}
301302

302303
impl<'list> Iterator for PathspecDiffEntries<'list> {
@@ -313,6 +314,7 @@ impl<'list> DoubleEndedIterator for PathspecDiffEntries<'list> {
313314
self.range.next_back().and_then(|i| self.list.diff_entry(i))
314315
}
315316
}
317+
impl<'list> FusedIterator for PathspecDiffEntries<'list> {}
316318
impl<'list> ExactSizeIterator for PathspecDiffEntries<'list> {}
317319

318320
impl<'list> Iterator for PathspecFailedEntries<'list> {
@@ -331,6 +333,7 @@ impl<'list> DoubleEndedIterator for PathspecFailedEntries<'list> {
331333
.and_then(|i| self.list.failed_entry(i))
332334
}
333335
}
336+
impl<'list> FusedIterator for PathspecFailedEntries<'list> {}
334337
impl<'list> ExactSizeIterator for PathspecFailedEntries<'list> {}
335338

336339
#[cfg(test)]

Diff for: src/reflog.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use libc::size_t;
2+
use std::iter::FusedIterator;
23
use std::marker;
34
use std::ops::Range;
45
use std::str;
@@ -174,6 +175,7 @@ impl<'reflog> DoubleEndedIterator for ReflogIter<'reflog> {
174175
self.range.next_back().and_then(|i| self.reflog.get(i))
175176
}
176177
}
178+
impl<'reflog> FusedIterator for ReflogIter<'reflog> {}
177179
impl<'reflog> ExactSizeIterator for ReflogIter<'reflog> {}
178180

179181
#[cfg(test)]

Diff for: src/remote.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use libc;
22
use raw::git_strarray;
3+
use std::iter::FusedIterator;
34
use std::marker;
45
use std::mem;
56
use std::ops::Range;
@@ -462,6 +463,7 @@ impl<'repo> DoubleEndedIterator for Refspecs<'repo> {
462463
.and_then(|i| self.remote.get_refspec(i))
463464
}
464465
}
466+
impl<'repo> FusedIterator for Refspecs<'repo> {}
465467
impl<'repo> ExactSizeIterator for Refspecs<'repo> {}
466468

467469
#[allow(missing_docs)] // not documented in libgit2 :(

Diff for: src/status.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use libc::{c_char, c_uint, size_t};
22
use std::ffi::CString;
3+
use std::iter::FusedIterator;
34
use std::marker;
45
use std::mem;
56
use std::ops::Range;
@@ -303,6 +304,7 @@ impl<'a> DoubleEndedIterator for StatusIter<'a> {
303304
self.range.next_back().and_then(|i| self.statuses.get(i))
304305
}
305306
}
307+
impl<'a> FusedIterator for StatusIter<'a> {}
306308
impl<'a> ExactSizeIterator for StatusIter<'a> {}
307309

308310
impl<'a> IntoIterator for &'a Statuses<'a> {

Diff for: src/string_array.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Bindings to libgit2's raw `git_strarray` type
22
3+
use std::iter::FusedIterator;
34
use std::ops::Range;
45
use std::str;
56

@@ -108,6 +109,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> {
108109
self.range.next_back().map(|i| self.arr.get(i))
109110
}
110111
}
112+
impl<'a> FusedIterator for Iter<'a> {}
111113
impl<'a> ExactSizeIterator for Iter<'a> {}
112114

113115
impl<'a> Iterator for IterBytes<'a> {
@@ -124,6 +126,7 @@ impl<'a> DoubleEndedIterator for IterBytes<'a> {
124126
self.range.next_back().and_then(|i| self.arr.get_bytes(i))
125127
}
126128
}
129+
impl<'a> FusedIterator for IterBytes<'a> {}
127130
impl<'a> ExactSizeIterator for IterBytes<'a> {}
128131

129132
impl Drop for StringArray {

Diff for: src/tree.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use libc::{self, c_char, c_int, c_void};
22
use std::cmp::Ordering;
33
use std::ffi::{CStr, CString};
4+
use std::iter::FusedIterator;
45
use std::marker;
56
use std::mem;
67
use std::ops::Range;
@@ -401,6 +402,7 @@ impl<'tree> DoubleEndedIterator for TreeIter<'tree> {
401402
self.range.next_back().and_then(|i| self.tree.get(i))
402403
}
403404
}
405+
impl<'tree> FusedIterator for TreeIter<'tree> {}
404406
impl<'tree> ExactSizeIterator for TreeIter<'tree> {}
405407

406408
#[cfg(test)]

0 commit comments

Comments
 (0)