summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-30 17:32:51 +0100
committerMartin Fischer <martin@push-f.com>2021-12-05 02:52:36 +0100
commit2cf4080bc7bc65092efdf64962862fa29c77c02c (patch)
tree93fd2c0da2c82ff09b7ba85b743b75321ead9b82 /src
parentb35817f2bbde6ba24d4286c9a1782815c28613a0 (diff)
spans: rename to SpanEmitter, adjust generics
Diffstat (limited to 'src')
-rw-r--r--src/spans.rs20
1 files changed, 11 insertions, 9 deletions
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<usize>;
+
/// The default implementation of [`crate::Emitter`], used to produce ("emit") tokens.
-pub struct DefaultEmitter<S, R> {
+pub struct SpanEmitter<R> {
current_characters: String,
- current_token: Option<Token<S>>,
+ current_token: Option<Token<Span>>,
last_start_tag: String,
current_attribute: Option<(String, String)>,
seen_attributes: BTreeSet<String>,
- emitted_tokens: VecDeque<Token<S>>,
+ emitted_tokens: VecDeque<Token<Span>>,
reader: PhantomData<R>,
}
-impl<S, R> Default for DefaultEmitter<S, R> {
+impl<R> Default for SpanEmitter<R> {
fn default() -> Self {
- DefaultEmitter {
+ SpanEmitter {
current_characters: String::new(),
current_token: None,
last_start_tag: String::new(),
@@ -31,8 +33,8 @@ impl<S, R> Default for DefaultEmitter<S, R> {
}
}
-impl<R> DefaultEmitter<(), R> {
- fn emit_token(&mut self, token: Token<()>) {
+impl<R> SpanEmitter<R> {
+ fn emit_token(&mut self, token: Token<Span>) {
self.flush_current_characters();
self.emitted_tokens.push_front(token);
}
@@ -75,8 +77,8 @@ impl<R> DefaultEmitter<(), R> {
}
}
-impl<R> Emitter<R> for DefaultEmitter<(), R> {
- type Token = Token<()>;
+impl<R> Emitter<R> for SpanEmitter<R> {
+ type Token = Token<Span>;
fn set_last_start_tag(&mut self, last_start_tag: Option<&str>) {
self.last_start_tag.clear();