diff --git a/src/lib.rs b/src/lib.rs index 5d07b720..e06f0bfa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1290,6 +1290,10 @@ pub mod token_stream { fn next(&mut self) -> Option { self.inner.next() } + + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } } impl Debug for IntoIter { diff --git a/tests/test.rs b/tests/test.rs index 86031db6..31d9a8df 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -547,6 +547,13 @@ fn default_tokenstream_is_empty() { assert!(default_token_stream.is_empty()); } +#[test] +fn tokenstream_size_hint() { + let tokens = "a b (c d) e".parse::().unwrap(); + + assert_eq!(tokens.into_iter().size_hint(), (4, Some(4))); +} + #[test] fn tuple_indexing() { // This behavior may change depending on https://github.com/rust-lang/rust/pull/71322