From 2cf4080bc7bc65092efdf64962862fa29c77c02c Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Tue, 30 Nov 2021 17:32:51 +0100 Subject: spans: rename to SpanEmitter, adjust generics --- src/spans.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/spans.rs b/src/spans.rs index ea3409c..cf65053 100644 --- a/src/spans.rs +++ b/src/spans.rs @@ -6,20 +6,22 @@ use std::{ use crate::{Doctype, Emitter, EndTag, Error, StartTag, Token}; +type Span = std::ops::Range; + /// The default implementation of [`crate::Emitter`], used to produce ("emit") tokens. -pub struct DefaultEmitter { +pub struct SpanEmitter { current_characters: String, - current_token: Option>, + current_token: Option>, last_start_tag: String, current_attribute: Option<(String, String)>, seen_attributes: BTreeSet, - emitted_tokens: VecDeque>, + emitted_tokens: VecDeque>, reader: PhantomData, } -impl Default for DefaultEmitter { +impl Default for SpanEmitter { fn default() -> Self { - DefaultEmitter { + SpanEmitter { current_characters: String::new(), current_token: None, last_start_tag: String::new(), @@ -31,8 +33,8 @@ impl Default for DefaultEmitter { } } -impl DefaultEmitter<(), R> { - fn emit_token(&mut self, token: Token<()>) { +impl SpanEmitter { + fn emit_token(&mut self, token: Token) { self.flush_current_characters(); self.emitted_tokens.push_front(token); } @@ -75,8 +77,8 @@ impl DefaultEmitter<(), R> { } } -impl Emitter for DefaultEmitter<(), R> { - type Token = Token<()>; +impl Emitter for SpanEmitter { + type Token = Token; fn set_last_start_tag(&mut self, last_start_tag: Option<&str>) { self.last_start_tag.clear(); -- cgit v1.2.3