diff --git a/examples/iron/src/main.rs b/examples/iron/src/main.rs index 065deaa..4fbde93 100644 --- a/examples/iron/src/main.rs +++ b/examples/iron/src/main.rs @@ -24,7 +24,7 @@ impl Modifier for Html { // argument of the type that the element that you're inserting it into expects, // which in the case of `` is `FlowContent`, not just `Node`, so you can't // pass it a `DOMTree` or you'll get a type error. -fn doc(tree: Box>) -> DOMTree { +fn doc(tree: Box>) -> DOMTree { html!( diff --git a/macros/src/declare.rs b/macros/src/declare.rs index 104de6b..9d900f1 100644 --- a/macros/src/declare.rs +++ b/macros/src/declare.rs @@ -103,7 +103,7 @@ impl Declare { } quote!( - pub struct #elem_name where T: crate::OutputType { + pub struct #elem_name where T: crate::OutputType + Send { pub attrs: #attr_type_name, pub data_attributes: Vec<(&'static str, String)>, pub events: T::Events, @@ -140,7 +140,7 @@ impl Declare { } quote!( - impl #elem_name where T: crate::OutputType { + impl #elem_name where T: crate::OutputType + Send { pub fn new(#args) -> Self { #elem_name { events: T::Events::default(), @@ -197,7 +197,7 @@ impl Declare { let elem_name = self.elem_name(); let vnode = self.impl_vnode(); quote!( - impl crate::dom::Node for #elem_name where T: crate::OutputType { + impl crate::dom::Node for #elem_name where T: crate::OutputType + Send { fn vnode(&'_ mut self) -> crate::dom::VNode<'_, T> { #vnode } @@ -225,7 +225,7 @@ impl Declare { } quote!( - impl crate::dom::Element for #elem_name where T: crate::OutputType { + impl crate::dom::Element for #elem_name where T: crate::OutputType + Send { fn name() -> &'static str { #name } @@ -256,7 +256,7 @@ impl Declare { for t in &self.traits { let name = t.clone(); body.extend(quote!( - impl #name for #elem_name where T: crate::OutputType {} + impl #name for #elem_name where T: crate::OutputType + Send {} )); } body @@ -265,7 +265,7 @@ impl Declare { fn impl_into_iter(&self) -> TokenStream { let elem_name = self.elem_name(); quote!( - impl IntoIterator for #elem_name where T: crate::OutputType { + impl IntoIterator for #elem_name where T: crate::OutputType + Send { type Item = #elem_name; type IntoIter = std::vec::IntoIter<#elem_name>; fn into_iter(self) -> Self::IntoIter { @@ -273,7 +273,7 @@ impl Declare { } } - impl IntoIterator for Box<#elem_name> where T: crate::OutputType { + impl IntoIterator for Box<#elem_name> where T: crate::OutputType + Send { type Item = Box<#elem_name>; type IntoIter = std::vec::IntoIter>>; fn into_iter(self) -> Self::IntoIter { @@ -348,7 +348,7 @@ impl Declare { quote!( impl std::fmt::Display for #elem_name where - T: crate::OutputType, + T: crate::OutputType + Send, { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { write!(f, "<{}", #name)?; diff --git a/typed-html/src/dom.rs b/typed-html/src/dom.rs index 8be1794..e728cd8 100644 --- a/typed-html/src/dom.rs +++ b/typed-html/src/dom.rs @@ -66,7 +66,7 @@ pub struct VElement<'a, T: OutputType + 'a> { /// [TextNode]: struct.TextNode.html /// [elements]: ../elements/index.html /// [vnode]: #tymethod.vnode -pub trait Node: Display { +pub trait Node: Display + Send { /// Render the node into a [`VNode`][VNode] tree. /// /// [VNode]: enum.VNode.html @@ -75,7 +75,7 @@ pub trait Node: Display { impl IntoIterator for Box> where - T: OutputType, + T: OutputType + Send, { type Item = Box>; type IntoIter = std::vec::IntoIter>>; @@ -90,7 +90,7 @@ where /// All [HTML elements][elements] implement this. /// /// [elements]: ../elements/index.html -pub trait Element: Node { +pub trait Element: Node { /// Get the name of the element. fn name() -> &'static str; /// Get a list of the attribute names for this element. @@ -112,7 +112,7 @@ pub trait Element: Node { } /// An HTML text node. -pub struct TextNode(String, PhantomData); +pub struct TextNode(String, PhantomData); /// Macro for creating text nodes. /// @@ -146,7 +146,7 @@ macro_rules! text { /// An unsafe HTML text node. /// This is like TextNode, but no escaping will be performed when this node is displayed. -pub struct UnsafeTextNode(String, PhantomData); +pub struct UnsafeTextNode(String, PhantomData); /// Macro for creating unescaped text nodes. /// @@ -186,7 +186,7 @@ macro_rules! unsafe_text { }; } -impl TextNode { +impl TextNode { /// Construct a text node. /// /// The preferred way to construct a text node is with the [`text!()`][text] @@ -198,19 +198,19 @@ impl TextNode { } } -impl Display for TextNode { +impl Display for TextNode { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { f.write_str(&encode_minimal(&self.0)) } } -impl Node for TextNode { +impl Node for TextNode { fn vnode(&'_ mut self) -> VNode<'_, T> { VNode::Text(&self.0) } } -impl IntoIterator for TextNode { +impl IntoIterator for TextNode { type Item = TextNode; type IntoIter = std::vec::IntoIter>; @@ -219,7 +219,7 @@ impl IntoIterator for TextNode { } } -impl IntoIterator for Box> { +impl IntoIterator for Box> { type Item = Box>; type IntoIter = std::vec::IntoIter>>; @@ -228,10 +228,10 @@ impl IntoIterator for Box> { } } -impl FlowContent for TextNode {} -impl PhrasingContent for TextNode {} +impl FlowContent for TextNode {} +impl PhrasingContent for TextNode {} -impl UnsafeTextNode { +impl UnsafeTextNode { /// Construct a unsafe text node. /// /// The preferred way to construct a unsafe text node is with the [`unsafe_text!()`][unsafe_text] @@ -243,19 +243,19 @@ impl UnsafeTextNode { } } -impl Display for UnsafeTextNode { +impl Display for UnsafeTextNode { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { f.write_str(&self.0) } } -impl Node for UnsafeTextNode { +impl Node for UnsafeTextNode { fn vnode(&'_ mut self) -> VNode<'_, T> { VNode::UnsafeText(&self.0) } } -impl IntoIterator for UnsafeTextNode { +impl IntoIterator for UnsafeTextNode { type Item = UnsafeTextNode; type IntoIter = std::vec::IntoIter>; @@ -264,7 +264,7 @@ impl IntoIterator for UnsafeTextNode { } } -impl IntoIterator for Box> { +impl IntoIterator for Box> { type Item = Box>; type IntoIter = std::vec::IntoIter>>; @@ -273,5 +273,5 @@ impl IntoIterator for Box> { } } -impl FlowContent for UnsafeTextNode {} -impl PhrasingContent for UnsafeTextNode {} +impl FlowContent for UnsafeTextNode {} +impl PhrasingContent for UnsafeTextNode {} diff --git a/typed-html/src/elements.rs b/typed-html/src/elements.rs index d089922..755b1da 100644 --- a/typed-html/src/elements.rs +++ b/typed-html/src/elements.rs @@ -16,9 +16,9 @@ macro_rules! marker_trait { }; ($trait:ident, $parent:ident) => { - pub trait $trait: $parent {} + pub trait $trait: $parent {} - impl IntoIterator for Box> where T: OutputType { + impl IntoIterator for Box> where T: OutputType + Send { type Item = Box>; type IntoIter = std::vec::IntoIter>>;