diff options
author | Martin Fischer <martin@push-f.com> | 2023-09-10 19:37:34 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2023-09-28 10:36:08 +0200 |
commit | 852d5c6f2e65a5ab466662ae1c649a0ed25c70a9 (patch) | |
tree | 96d6bcdb2f2274f1081a0b6cfbde314f319159a1 /src/emitter.rs | |
parent | a03cea75d9d120a7519be91ec872b143b5d74276 (diff) |
break!: move offsets out of Token
Previously the Token enum contained the offsets using the O generic
type parameter, which could be a usize if you're tracking offsets or
a zero-sized type if you didn't care about offsets. This commit moves
all the byte offset and syntax information to a new Trace enum,
which has several advantages:
* Traces can now easily be stored separately, while the tokens are
fed to the tree builder. (The tree builder only has to keep track
of which tree nodes originate from which tokens.)
* No needless generics for functions that take a token but don't
care about offsets (a tree construction implementation is bound
to have many of such functions).
* The FromIterator<(String, String)> impl for AttributeMap no longer
has to specify arbitrary values for the spans and the value_syntax).
* The PartialEq implementation of Token is now much more useful
(since it no longer includes all the offsets).
* The Debug formatting of Token is now more readable
(since it no longer includes all the offsets).
* Function pointers to functions accepting tokens are possible.
(Since function pointer types may not have generic parameters.)
Diffstat (limited to 'src/emitter.rs')
-rw-r--r-- | src/emitter.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/emitter.rs b/src/emitter.rs index 25e0209..d1e1dfe 100644 --- a/src/emitter.rs +++ b/src/emitter.rs @@ -1,6 +1,6 @@ use std::ops::Range; -use crate::token::AttrValueSyntax; +use crate::trace::AttrValueSyntax; use crate::Error; /// An emitter is an object providing methods to the tokenizer to produce ("emit") tokens. |