Skip to content

Commit

Permalink
Expose size_hint() for TokenStream's iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 25, 2022
1 parent f427365 commit 25a20e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/lib.rs
Expand Up @@ -1290,6 +1290,10 @@ pub mod token_stream {
fn next(&mut self) -> Option<TokenTree> {
self.inner.next()
}

fn size_hint(&self) -> (usize, Option<usize>) {
self.inner.size_hint()
}
}

impl Debug for IntoIter {
Expand Down
2 changes: 1 addition & 1 deletion tests/test.rs
Expand Up @@ -551,7 +551,7 @@ fn default_tokenstream_is_empty() {
fn tokenstream_size_hint() {
let tokens = "a b (c d) e".parse::<TokenStream>().unwrap();

assert_eq!(tokens.into_iter().size_hint(), (0, None)); // FIXME
assert_eq!(tokens.into_iter().size_hint(), (4, Some(4)));
}

#[test]
Expand Down

0 comments on commit 25a20e0

Please sign in to comment.