mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 08:23:24 +01:00
Impl FusedIterator
for record iterators (#12542)
This is good practice as all our iterators will never return a value after reaching `None` The benefit should be minimal as only `Iterator::fuse` is directly specialized and itself rarely used (sometimes in `itertools` adaptors) Thus it is mostly a documentation thing
This commit is contained in:
parent
a67dad3d15
commit
055aae9f5c
@ -1,4 +1,4 @@
|
||||
use std::ops::RangeBounds;
|
||||
use std::{iter::FusedIterator, ops::RangeBounds};
|
||||
|
||||
use crate::{ShellError, Span, Value};
|
||||
|
||||
@ -409,6 +409,8 @@ impl ExactSizeIterator for IntoIter {
|
||||
}
|
||||
}
|
||||
|
||||
impl FusedIterator for IntoIter {}
|
||||
|
||||
impl IntoIterator for Record {
|
||||
type Item = (String, Value);
|
||||
|
||||
@ -449,6 +451,8 @@ impl<'a> ExactSizeIterator for Iter<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl FusedIterator for Iter<'_> {}
|
||||
|
||||
impl<'a> IntoIterator for &'a Record {
|
||||
type Item = (&'a String, &'a Value);
|
||||
|
||||
@ -489,6 +493,8 @@ impl<'a> ExactSizeIterator for IterMut<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl FusedIterator for IterMut<'_> {}
|
||||
|
||||
impl<'a> IntoIterator for &'a mut Record {
|
||||
type Item = (&'a String, &'a mut Value);
|
||||
|
||||
@ -529,6 +535,8 @@ impl<'a> ExactSizeIterator for Columns<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl FusedIterator for Columns<'_> {}
|
||||
|
||||
pub struct IntoColumns {
|
||||
iter: std::vec::IntoIter<(String, Value)>,
|
||||
}
|
||||
@ -557,6 +565,8 @@ impl ExactSizeIterator for IntoColumns {
|
||||
}
|
||||
}
|
||||
|
||||
impl FusedIterator for IntoColumns {}
|
||||
|
||||
pub struct Values<'a> {
|
||||
iter: std::slice::Iter<'a, (String, Value)>,
|
||||
}
|
||||
@ -585,6 +595,8 @@ impl<'a> ExactSizeIterator for Values<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl FusedIterator for Values<'_> {}
|
||||
|
||||
pub struct IntoValues {
|
||||
iter: std::vec::IntoIter<(String, Value)>,
|
||||
}
|
||||
@ -613,6 +625,8 @@ impl ExactSizeIterator for IntoValues {
|
||||
}
|
||||
}
|
||||
|
||||
impl FusedIterator for IntoValues {}
|
||||
|
||||
pub struct Drain<'a> {
|
||||
iter: std::vec::Drain<'a, (String, Value)>,
|
||||
}
|
||||
@ -641,6 +655,8 @@ impl ExactSizeIterator for Drain<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl FusedIterator for Drain<'_> {}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! record {
|
||||
// The macro only compiles if the number of columns equals the number of values,
|
||||
|
Loading…
Reference in New Issue
Block a user