Add Send to all output types
This commit is contained in:
parent
62dd064f79
commit
8c340453eb
|
@ -24,7 +24,7 @@ impl Modifier<Response> for Html {
|
|||
// argument of the type that the element that you're inserting it into expects,
|
||||
// which in the case of `<body>` is `FlowContent`, not just `Node`, so you can't
|
||||
// pass it a `DOMTree<T>` or you'll get a type error.
|
||||
fn doc<T: OutputType + 'static>(tree: Box<dyn FlowContent<T>>) -> DOMTree<T> {
|
||||
fn doc<T: OutputType + 'static + Send>(tree: Box<dyn FlowContent<T>>) -> DOMTree<T> {
|
||||
html!(
|
||||
<html>
|
||||
<head>
|
||||
|
|
|
@ -103,7 +103,7 @@ impl Declare {
|
|||
}
|
||||
|
||||
quote!(
|
||||
pub struct #elem_name<T> where T: crate::OutputType {
|
||||
pub struct #elem_name<T> 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<T> #elem_name<T> where T: crate::OutputType {
|
||||
impl<T> #elem_name<T> 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<T> crate::dom::Node<T> for #elem_name<T> where T: crate::OutputType {
|
||||
impl<T> crate::dom::Node<T> for #elem_name<T> where T: crate::OutputType + Send {
|
||||
fn vnode(&'_ mut self) -> crate::dom::VNode<'_, T> {
|
||||
#vnode
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ impl Declare {
|
|||
}
|
||||
|
||||
quote!(
|
||||
impl<T> crate::dom::Element<T> for #elem_name<T> where T: crate::OutputType {
|
||||
impl<T> crate::dom::Element<T> for #elem_name<T> 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<T> #name<T> for #elem_name<T> where T: crate::OutputType {}
|
||||
impl<T> #name<T> for #elem_name<T> 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<T> IntoIterator for #elem_name<T> where T: crate::OutputType {
|
||||
impl<T> IntoIterator for #elem_name<T> where T: crate::OutputType + Send {
|
||||
type Item = #elem_name<T>;
|
||||
type IntoIter = std::vec::IntoIter<#elem_name<T>>;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
|
@ -273,7 +273,7 @@ impl Declare {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> IntoIterator for Box<#elem_name<T>> where T: crate::OutputType {
|
||||
impl<T> IntoIterator for Box<#elem_name<T>> where T: crate::OutputType + Send {
|
||||
type Item = Box<#elem_name<T>>;
|
||||
type IntoIter = std::vec::IntoIter<Box<#elem_name<T>>>;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
|
@ -348,7 +348,7 @@ impl Declare {
|
|||
quote!(
|
||||
impl<T> std::fmt::Display for #elem_name<T>
|
||||
where
|
||||
T: crate::OutputType,
|
||||
T: crate::OutputType + Send,
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||
write!(f, "<{}", #name)?;
|
||||
|
|
|
@ -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<T: OutputType>: Display {
|
||||
pub trait Node<T: OutputType + Send>: Display + Send {
|
||||
/// Render the node into a [`VNode`][VNode] tree.
|
||||
///
|
||||
/// [VNode]: enum.VNode.html
|
||||
|
@ -75,7 +75,7 @@ pub trait Node<T: OutputType>: Display {
|
|||
|
||||
impl<T> IntoIterator for Box<dyn Node<T>>
|
||||
where
|
||||
T: OutputType,
|
||||
T: OutputType + Send,
|
||||
{
|
||||
type Item = Box<dyn Node<T>>;
|
||||
type IntoIter = std::vec::IntoIter<Box<dyn Node<T>>>;
|
||||
|
@ -90,7 +90,7 @@ where
|
|||
/// All [HTML elements][elements] implement this.
|
||||
///
|
||||
/// [elements]: ../elements/index.html
|
||||
pub trait Element<T: OutputType>: Node<T> {
|
||||
pub trait Element<T: OutputType + Send>: Node<T> {
|
||||
/// 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<T: OutputType>: Node<T> {
|
|||
}
|
||||
|
||||
/// An HTML text node.
|
||||
pub struct TextNode<T: OutputType>(String, PhantomData<T>);
|
||||
pub struct TextNode<T: OutputType + Send>(String, PhantomData<T>);
|
||||
|
||||
/// 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<T: OutputType>(String, PhantomData<T>);
|
||||
pub struct UnsafeTextNode<T: OutputType + Send>(String, PhantomData<T>);
|
||||
|
||||
/// Macro for creating unescaped text nodes.
|
||||
///
|
||||
|
@ -186,7 +186,7 @@ macro_rules! unsafe_text {
|
|||
};
|
||||
}
|
||||
|
||||
impl<T: OutputType> TextNode<T> {
|
||||
impl<T: OutputType + Send> TextNode<T> {
|
||||
/// Construct a text node.
|
||||
///
|
||||
/// The preferred way to construct a text node is with the [`text!()`][text]
|
||||
|
@ -198,19 +198,19 @@ impl<T: OutputType> TextNode<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: OutputType> Display for TextNode<T> {
|
||||
impl<T: OutputType + Send> Display for TextNode<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||
f.write_str(&encode_minimal(&self.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: OutputType> Node<T> for TextNode<T> {
|
||||
impl<T: OutputType + Send> Node<T> for TextNode<T> {
|
||||
fn vnode(&'_ mut self) -> VNode<'_, T> {
|
||||
VNode::Text(&self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: OutputType> IntoIterator for TextNode<T> {
|
||||
impl<T: OutputType + Send> IntoIterator for TextNode<T> {
|
||||
type Item = TextNode<T>;
|
||||
type IntoIter = std::vec::IntoIter<TextNode<T>>;
|
||||
|
||||
|
@ -219,7 +219,7 @@ impl<T: OutputType> IntoIterator for TextNode<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: OutputType> IntoIterator for Box<TextNode<T>> {
|
||||
impl<T: OutputType + Send> IntoIterator for Box<TextNode<T>> {
|
||||
type Item = Box<TextNode<T>>;
|
||||
type IntoIter = std::vec::IntoIter<Box<TextNode<T>>>;
|
||||
|
||||
|
@ -228,10 +228,10 @@ impl<T: OutputType> IntoIterator for Box<TextNode<T>> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: OutputType> FlowContent<T> for TextNode<T> {}
|
||||
impl<T: OutputType> PhrasingContent<T> for TextNode<T> {}
|
||||
impl<T: OutputType + Send> FlowContent<T> for TextNode<T> {}
|
||||
impl<T: OutputType + Send> PhrasingContent<T> for TextNode<T> {}
|
||||
|
||||
impl<T: OutputType> UnsafeTextNode<T> {
|
||||
impl<T: OutputType + Send> UnsafeTextNode<T> {
|
||||
/// 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<T: OutputType> UnsafeTextNode<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: OutputType> Display for UnsafeTextNode<T> {
|
||||
impl<T: OutputType + Send> Display for UnsafeTextNode<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||
f.write_str(&self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: OutputType> Node<T> for UnsafeTextNode<T> {
|
||||
impl<T: OutputType + Send> Node<T> for UnsafeTextNode<T> {
|
||||
fn vnode(&'_ mut self) -> VNode<'_, T> {
|
||||
VNode::UnsafeText(&self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: OutputType> IntoIterator for UnsafeTextNode<T> {
|
||||
impl<T: OutputType + Send> IntoIterator for UnsafeTextNode<T> {
|
||||
type Item = UnsafeTextNode<T>;
|
||||
type IntoIter = std::vec::IntoIter<UnsafeTextNode<T>>;
|
||||
|
||||
|
@ -264,7 +264,7 @@ impl<T: OutputType> IntoIterator for UnsafeTextNode<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: OutputType> IntoIterator for Box<UnsafeTextNode<T>> {
|
||||
impl<T: OutputType + Send> IntoIterator for Box<UnsafeTextNode<T>> {
|
||||
type Item = Box<UnsafeTextNode<T>>;
|
||||
type IntoIter = std::vec::IntoIter<Box<UnsafeTextNode<T>>>;
|
||||
|
||||
|
@ -273,5 +273,5 @@ impl<T: OutputType> IntoIterator for Box<UnsafeTextNode<T>> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: OutputType> FlowContent<T> for UnsafeTextNode<T> {}
|
||||
impl<T: OutputType> PhrasingContent<T> for UnsafeTextNode<T> {}
|
||||
impl<T: OutputType + Send> FlowContent<T> for UnsafeTextNode<T> {}
|
||||
impl<T: OutputType + Send> PhrasingContent<T> for UnsafeTextNode<T> {}
|
||||
|
|
|
@ -16,9 +16,9 @@ macro_rules! marker_trait {
|
|||
};
|
||||
|
||||
($trait:ident, $parent:ident) => {
|
||||
pub trait $trait<T: OutputType>: $parent<T> {}
|
||||
pub trait $trait<T: OutputType + Send>: $parent<T> {}
|
||||
|
||||
impl<T> IntoIterator for Box<dyn $trait<T>> where T: OutputType {
|
||||
impl<T> IntoIterator for Box<dyn $trait<T>> where T: OutputType + Send {
|
||||
type Item = Box<dyn $trait<T>>;
|
||||
type IntoIter = std::vec::IntoIter<Box<dyn $trait<T>>>;
|
||||
|
||||
|
|
Loading…
Reference in New Issue