aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-08-29 13:09:44 +0200
committerMartin Fischer <martin@push-f.com>2023-09-28 10:36:01 +0200
commit826907487e2b593f1c54e98b59fe2f6eb8cb6937 (patch)
treede48a91090a240033a6f02eb8e984da133b71025 /examples
parent2b4c52758c503b08d3299ad2d1ee369ad5f597f1 (diff)
break!: remove Token::Error
An error isn't a token (in general and also according to the spec). You shouldn't have to filter out errors when you're just interested in tokens but most importantly having errors in the Token enum is annoying when implementing tree construction (since the spec conditions exhaustively cover all Token variants except Token::Error).
Diffstat (limited to 'examples')
-rw-r--r--examples/tokenize.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/examples/tokenize.rs b/examples/tokenize.rs
index da99dd3..f8859e4 100644
--- a/examples/tokenize.rs
+++ b/examples/tokenize.rs
@@ -5,12 +5,15 @@ use html5tokenizer::{DefaultEmitter, Tokenizer};
use std::io::BufReader;
fn main() {
- for token in Tokenizer::new(
+ let mut tokenizer = Tokenizer::new(
BufReader::new(std::io::stdin().lock()),
DefaultEmitter::default(),
- )
- .flatten()
- {
+ );
+ while let Some(token) = tokenizer.next() {
+ for (error, _) in tokenizer.emitter_mut().drain_errors() {
+ eprintln!("error: {:?}", error);
+ }
+ let token = token.unwrap();
println!("{:?}", token);
}
}