aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-09-01 09:06:44 +0200
committerMartin Fischer <martin@push-f.com>2023-09-28 10:36:08 +0200
commitc75dce875cff03e59ec7b6bceed4ec63283a6477 (patch)
treef478ed26b04a965cd3e5fb1604ed204187cc64be
parentbd446b6123e0b077a48e9f1e836affac78822f44 (diff)
feat: impl Clone for Token & Event
-rw-r--r--CHANGELOG.md2
-rw-r--r--src/token.rs12
-rw-r--r--src/tokenizer.rs2
3 files changed, 9 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d35ffc3..3f175d7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,8 @@
* Added offsets for end-of-file tokens.
+* Implemented `Clone` for `Token` (and all contained types) and `Event`.
+
* Added a blanket implementation to implement `Reader` for boxed readers.
#### Breaking changes
diff --git a/src/token.rs b/src/token.rs
index 4f3c0ce..45c8123 100644
--- a/src/token.rs
+++ b/src/token.rs
@@ -5,7 +5,7 @@ use std::iter::FromIterator;
use std::ops::Index;
/// A type for the tokens emitted by a WHATWG-compliant HTML tokenizer.
-#[derive(Debug, Eq, PartialEq)]
+#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Token {
/// A literal character, a resolved character reference,
/// or part of a resolved character reference (since some
@@ -24,7 +24,7 @@ pub enum Token {
}
/// An HTML start tag, such as `<p>` or `<a>`.
-#[derive(Debug, Eq, PartialEq)]
+#[derive(Clone, Debug, Eq, PartialEq)]
pub struct StartTag {
/// Whether this tag is self-closing. If it is self-closing, no following [`EndTag`] should be
/// expected.
@@ -41,7 +41,7 @@ pub struct StartTag {
}
/// An HTML end/close tag, such as `</p>` or `</a>`.
-#[derive(Debug, Eq, PartialEq)]
+#[derive(Clone, Debug, Eq, PartialEq)]
pub struct EndTag {
/// The tag name.
/// Uppercase ASCII characters (A-Z) have been converted to lowercase.
@@ -54,7 +54,7 @@ pub struct EndTag {
/// * `<!DOCTYPE {name} PUBLIC '{public_id}'>`
/// * `<!DOCTYPE {name} SYSTEM '{system_id}'>`
/// * `<!DOCTYPE {name} PUBLIC '{public_id}' '{system_id}'>`
-#[derive(Debug, Eq, PartialEq)]
+#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Doctype {
/// The [force-quirks flag].
///
@@ -86,14 +86,14 @@ pub struct Doctype {
/// .collect();
/// assert_eq!(&attrs["href"], "http://example.com");
/// ```
-#[derive(Debug, Default, PartialEq, Eq)]
+#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct AttributeMap {
pub(crate) inner: BTreeMap<String, AttrInternal>,
}
/// The value type internally used by the [`AttributeMap`].
/// Not part of the public API.
-#[derive(Default, Debug, Eq)]
+#[derive(Clone, Default, Debug, Eq)]
pub(crate) struct AttrInternal {
pub value: String,
pub trace_idx: Option<AttributeTraceIdx>,
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index 661214c..83b18e1 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -72,7 +72,7 @@ impl<R: Reader + Position<O>, O: Offset, E: Emitter<O>> Tokenizer<R, O, E> {
}
/// An event yielded by the [`Iterator`] implementation for the [`Tokenizer`].
-#[derive(Debug)]
+#[derive(Clone, Debug)]
pub enum Event<T> {
/// A token emitted by the [`Emitter`].
Token(T),