aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/document_tree/elements.rs13
-rw-r--r--src/renderer/html.rs2
2 files changed, 14 insertions, 1 deletions
diff --git a/src/document_tree/elements.rs b/src/document_tree/elements.rs
index f717f6a..7406cd7 100644
--- a/src/document_tree/elements.rs
+++ b/src/document_tree/elements.rs
@@ -74,6 +74,19 @@ macro_rules! impl_extra { ($name:ident $($more:tt)*) => (
}
)}
+trait HasExtraAndChildren<C, A> {
+ fn with_extra_and_children(extra: A, children: Vec<C>) -> Self;
+}
+
+impl<T, C, A> HasExtraAndChildren<C, A> for T where T: HasChildren<C> + ExtraAttributes<A> {
+ #[allow(clippy::needless_update)]
+ fn with_extra_and_children(extra: A, mut children: Vec<C>) -> Self {
+ let mut r = Self::with_extra(extra);
+ r.children_mut().extend(children.drain(..));
+ r
+ }
+}
+
macro_rules! impl_new {(
$(#[$attr:meta])*
pub struct $name:ident { $(
diff --git a/src/renderer/html.rs b/src/renderer/html.rs
index 69a4430..6041ec0 100644
--- a/src/renderer/html.rs
+++ b/src/renderer/html.rs
@@ -1,6 +1,6 @@
use std::io::Write;
-use failure::{Error, Fail};
+use failure::Error;
// use crate::url::Url;
use crate::document_tree::{