Skip to content

Commit 9dc1d47

Browse files
committed
Merge #398: Implement is_empty on TokenIter
cb51a5b Implement is_empty on TokenIter (Tobin C. Harding) Pull request description: Clippy emits: ``` warning: struct `TokenIter` has a public `len` method, but no `is_empty` method --> src/miniscript/lex.rs:102:5 | 102 | pub fn len(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(clippy::len_without_is_empty)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty ``` Iterators typically do not implement `is_empty` because there is often no way for an iterator to know if there are more items without calling `next`, however we use a `Vec` under the hood so `is_empty` is cheap. Implement `is_empty` on the `TokenIter` struct. Top commit has no ACKs. Tree-SHA512: b0b832ac9457b9eef725b4589198212d90ea66faa4788792551da31a7601b928edbd7658f33862ed8210478cc4512af4ebb35be1cddf9d66ac67f6222f282a3e
2 parents 43eb331 + cb51a5b commit 9dc1d47

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/miniscript/lex.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ impl<'s> TokenIter<'s> {
102102
pub fn len(&self) -> usize {
103103
self.0.len()
104104
}
105+
106+
/// Returns true if iterator is empty.
107+
pub fn is_empty(&self) -> bool {
108+
self.0.is_empty()
109+
}
105110
}
106111

107112
impl<'s> Iterator for TokenIter<'s> {

0 commit comments

Comments
 (0)