Skip to content

Commit cc40ed7

Browse files
committed
Implement FusedIterator for those which inherit the property from std's iterators.
1 parent 24ee7eb commit cc40ed7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/iter.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::iter::FusedIterator;
12
use std::ops::Range;
23
use std::{slice, vec};
34

@@ -7,6 +8,7 @@ use {Node, NodeId, NodeRef, Tree};
78
#[derive(Debug)]
89
pub struct IntoIter<T>(vec::IntoIter<Node<T>>);
910
impl<T> ExactSizeIterator for IntoIter<T> {}
11+
impl<T> FusedIterator for IntoIter<T> {}
1012
impl<T> Iterator for IntoIter<T> {
1113
type Item = T;
1214
fn next(&mut self) -> Option<Self::Item> {
@@ -31,6 +33,7 @@ impl<'a, T: 'a> Clone for Values<'a, T> {
3133
}
3234
}
3335
impl<'a, T: 'a> ExactSizeIterator for Values<'a, T> {}
36+
impl<'a, T: 'a> FusedIterator for Values<'a, T> {}
3437
impl<'a, T: 'a> Iterator for Values<'a, T> {
3538
type Item = &'a T;
3639
fn next(&mut self) -> Option<Self::Item> {
@@ -50,6 +53,7 @@ impl<'a, T: 'a> DoubleEndedIterator for Values<'a, T> {
5053
#[derive(Debug)]
5154
pub struct ValuesMut<'a, T: 'a>(slice::IterMut<'a, Node<T>>);
5255
impl<'a, T: 'a> ExactSizeIterator for ValuesMut<'a, T> {}
56+
impl<'a, T: 'a> FusedIterator for ValuesMut<'a, T> {}
5357
impl<'a, T: 'a> Iterator for ValuesMut<'a, T> {
5458
type Item = &'a mut T;
5559
fn next(&mut self) -> Option<Self::Item> {
@@ -80,6 +84,7 @@ impl<'a, T: 'a> Clone for Nodes<'a, T> {
8084
}
8185
}
8286
impl<'a, T: 'a> ExactSizeIterator for Nodes<'a, T> {}
87+
impl<'a, T: 'a> FusedIterator for Nodes<'a, T> {}
8388
impl<'a, T: 'a> Iterator for Nodes<'a, T> {
8489
type Item = NodeRef<'a, T>;
8590
fn next(&mut self) -> Option<Self::Item> {

0 commit comments

Comments
 (0)