Skip to content

Commit 8c34045

Browse files
jonathanKingstonbodil
authored andcommitted
Add Send to all output types
1 parent 62dd064 commit 8c34045

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

examples/iron/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl Modifier<Response> for Html {
2424
// argument of the type that the element that you're inserting it into expects,
2525
// which in the case of `<body>` is `FlowContent`, not just `Node`, so you can't
2626
// pass it a `DOMTree<T>` or you'll get a type error.
27-
fn doc<T: OutputType + 'static>(tree: Box<dyn FlowContent<T>>) -> DOMTree<T> {
27+
fn doc<T: OutputType + 'static + Send>(tree: Box<dyn FlowContent<T>>) -> DOMTree<T> {
2828
html!(
2929
<html>
3030
<head>

macros/src/declare.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl Declare {
103103
}
104104

105105
quote!(
106-
pub struct #elem_name<T> where T: crate::OutputType {
106+
pub struct #elem_name<T> where T: crate::OutputType + Send {
107107
pub attrs: #attr_type_name,
108108
pub data_attributes: Vec<(&'static str, String)>,
109109
pub events: T::Events,
@@ -140,7 +140,7 @@ impl Declare {
140140
}
141141

142142
quote!(
143-
impl<T> #elem_name<T> where T: crate::OutputType {
143+
impl<T> #elem_name<T> where T: crate::OutputType + Send {
144144
pub fn new(#args) -> Self {
145145
#elem_name {
146146
events: T::Events::default(),
@@ -197,7 +197,7 @@ impl Declare {
197197
let elem_name = self.elem_name();
198198
let vnode = self.impl_vnode();
199199
quote!(
200-
impl<T> crate::dom::Node<T> for #elem_name<T> where T: crate::OutputType {
200+
impl<T> crate::dom::Node<T> for #elem_name<T> where T: crate::OutputType + Send {
201201
fn vnode(&'_ mut self) -> crate::dom::VNode<'_, T> {
202202
#vnode
203203
}
@@ -225,7 +225,7 @@ impl Declare {
225225
}
226226

227227
quote!(
228-
impl<T> crate::dom::Element<T> for #elem_name<T> where T: crate::OutputType {
228+
impl<T> crate::dom::Element<T> for #elem_name<T> where T: crate::OutputType + Send {
229229
fn name() -> &'static str {
230230
#name
231231
}
@@ -256,7 +256,7 @@ impl Declare {
256256
for t in &self.traits {
257257
let name = t.clone();
258258
body.extend(quote!(
259-
impl<T> #name<T> for #elem_name<T> where T: crate::OutputType {}
259+
impl<T> #name<T> for #elem_name<T> where T: crate::OutputType + Send {}
260260
));
261261
}
262262
body
@@ -265,15 +265,15 @@ impl Declare {
265265
fn impl_into_iter(&self) -> TokenStream {
266266
let elem_name = self.elem_name();
267267
quote!(
268-
impl<T> IntoIterator for #elem_name<T> where T: crate::OutputType {
268+
impl<T> IntoIterator for #elem_name<T> where T: crate::OutputType + Send {
269269
type Item = #elem_name<T>;
270270
type IntoIter = std::vec::IntoIter<#elem_name<T>>;
271271
fn into_iter(self) -> Self::IntoIter {
272272
vec![self].into_iter()
273273
}
274274
}
275275

276-
impl<T> IntoIterator for Box<#elem_name<T>> where T: crate::OutputType {
276+
impl<T> IntoIterator for Box<#elem_name<T>> where T: crate::OutputType + Send {
277277
type Item = Box<#elem_name<T>>;
278278
type IntoIter = std::vec::IntoIter<Box<#elem_name<T>>>;
279279
fn into_iter(self) -> Self::IntoIter {
@@ -348,7 +348,7 @@ impl Declare {
348348
quote!(
349349
impl<T> std::fmt::Display for #elem_name<T>
350350
where
351-
T: crate::OutputType,
351+
T: crate::OutputType + Send,
352352
{
353353
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
354354
write!(f, "<{}", #name)?;

typed-html/src/dom.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub struct VElement<'a, T: OutputType + 'a> {
6666
/// [TextNode]: struct.TextNode.html
6767
/// [elements]: ../elements/index.html
6868
/// [vnode]: #tymethod.vnode
69-
pub trait Node<T: OutputType>: Display {
69+
pub trait Node<T: OutputType + Send>: Display + Send {
7070
/// Render the node into a [`VNode`][VNode] tree.
7171
///
7272
/// [VNode]: enum.VNode.html
@@ -75,7 +75,7 @@ pub trait Node<T: OutputType>: Display {
7575

7676
impl<T> IntoIterator for Box<dyn Node<T>>
7777
where
78-
T: OutputType,
78+
T: OutputType + Send,
7979
{
8080
type Item = Box<dyn Node<T>>;
8181
type IntoIter = std::vec::IntoIter<Box<dyn Node<T>>>;
@@ -90,7 +90,7 @@ where
9090
/// All [HTML elements][elements] implement this.
9191
///
9292
/// [elements]: ../elements/index.html
93-
pub trait Element<T: OutputType>: Node<T> {
93+
pub trait Element<T: OutputType + Send>: Node<T> {
9494
/// Get the name of the element.
9595
fn name() -> &'static str;
9696
/// Get a list of the attribute names for this element.
@@ -112,7 +112,7 @@ pub trait Element<T: OutputType>: Node<T> {
112112
}
113113

114114
/// An HTML text node.
115-
pub struct TextNode<T: OutputType>(String, PhantomData<T>);
115+
pub struct TextNode<T: OutputType + Send>(String, PhantomData<T>);
116116

117117
/// Macro for creating text nodes.
118118
///
@@ -146,7 +146,7 @@ macro_rules! text {
146146

147147
/// An unsafe HTML text node.
148148
/// This is like TextNode, but no escaping will be performed when this node is displayed.
149-
pub struct UnsafeTextNode<T: OutputType>(String, PhantomData<T>);
149+
pub struct UnsafeTextNode<T: OutputType + Send>(String, PhantomData<T>);
150150

151151
/// Macro for creating unescaped text nodes.
152152
///
@@ -186,7 +186,7 @@ macro_rules! unsafe_text {
186186
};
187187
}
188188

189-
impl<T: OutputType> TextNode<T> {
189+
impl<T: OutputType + Send> TextNode<T> {
190190
/// Construct a text node.
191191
///
192192
/// The preferred way to construct a text node is with the [`text!()`][text]
@@ -198,19 +198,19 @@ impl<T: OutputType> TextNode<T> {
198198
}
199199
}
200200

201-
impl<T: OutputType> Display for TextNode<T> {
201+
impl<T: OutputType + Send> Display for TextNode<T> {
202202
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
203203
f.write_str(&encode_minimal(&self.0))
204204
}
205205
}
206206

207-
impl<T: OutputType> Node<T> for TextNode<T> {
207+
impl<T: OutputType + Send> Node<T> for TextNode<T> {
208208
fn vnode(&'_ mut self) -> VNode<'_, T> {
209209
VNode::Text(&self.0)
210210
}
211211
}
212212

213-
impl<T: OutputType> IntoIterator for TextNode<T> {
213+
impl<T: OutputType + Send> IntoIterator for TextNode<T> {
214214
type Item = TextNode<T>;
215215
type IntoIter = std::vec::IntoIter<TextNode<T>>;
216216

@@ -219,7 +219,7 @@ impl<T: OutputType> IntoIterator for TextNode<T> {
219219
}
220220
}
221221

222-
impl<T: OutputType> IntoIterator for Box<TextNode<T>> {
222+
impl<T: OutputType + Send> IntoIterator for Box<TextNode<T>> {
223223
type Item = Box<TextNode<T>>;
224224
type IntoIter = std::vec::IntoIter<Box<TextNode<T>>>;
225225

@@ -228,10 +228,10 @@ impl<T: OutputType> IntoIterator for Box<TextNode<T>> {
228228
}
229229
}
230230

231-
impl<T: OutputType> FlowContent<T> for TextNode<T> {}
232-
impl<T: OutputType> PhrasingContent<T> for TextNode<T> {}
231+
impl<T: OutputType + Send> FlowContent<T> for TextNode<T> {}
232+
impl<T: OutputType + Send> PhrasingContent<T> for TextNode<T> {}
233233

234-
impl<T: OutputType> UnsafeTextNode<T> {
234+
impl<T: OutputType + Send> UnsafeTextNode<T> {
235235
/// Construct a unsafe text node.
236236
///
237237
/// 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> {
243243
}
244244
}
245245

246-
impl<T: OutputType> Display for UnsafeTextNode<T> {
246+
impl<T: OutputType + Send> Display for UnsafeTextNode<T> {
247247
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
248248
f.write_str(&self.0)
249249
}
250250
}
251251

252-
impl<T: OutputType> Node<T> for UnsafeTextNode<T> {
252+
impl<T: OutputType + Send> Node<T> for UnsafeTextNode<T> {
253253
fn vnode(&'_ mut self) -> VNode<'_, T> {
254254
VNode::UnsafeText(&self.0)
255255
}
256256
}
257257

258-
impl<T: OutputType> IntoIterator for UnsafeTextNode<T> {
258+
impl<T: OutputType + Send> IntoIterator for UnsafeTextNode<T> {
259259
type Item = UnsafeTextNode<T>;
260260
type IntoIter = std::vec::IntoIter<UnsafeTextNode<T>>;
261261

@@ -264,7 +264,7 @@ impl<T: OutputType> IntoIterator for UnsafeTextNode<T> {
264264
}
265265
}
266266

267-
impl<T: OutputType> IntoIterator for Box<UnsafeTextNode<T>> {
267+
impl<T: OutputType + Send> IntoIterator for Box<UnsafeTextNode<T>> {
268268
type Item = Box<UnsafeTextNode<T>>;
269269
type IntoIter = std::vec::IntoIter<Box<UnsafeTextNode<T>>>;
270270

@@ -273,5 +273,5 @@ impl<T: OutputType> IntoIterator for Box<UnsafeTextNode<T>> {
273273
}
274274
}
275275

276-
impl<T: OutputType> FlowContent<T> for UnsafeTextNode<T> {}
277-
impl<T: OutputType> PhrasingContent<T> for UnsafeTextNode<T> {}
276+
impl<T: OutputType + Send> FlowContent<T> for UnsafeTextNode<T> {}
277+
impl<T: OutputType + Send> PhrasingContent<T> for UnsafeTextNode<T> {}

typed-html/src/elements.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ macro_rules! marker_trait {
1616
};
1717

1818
($trait:ident, $parent:ident) => {
19-
pub trait $trait<T: OutputType>: $parent<T> {}
19+
pub trait $trait<T: OutputType + Send>: $parent<T> {}
2020

21-
impl<T> IntoIterator for Box<dyn $trait<T>> where T: OutputType {
21+
impl<T> IntoIterator for Box<dyn $trait<T>> where T: OutputType + Send {
2222
type Item = Box<dyn $trait<T>>;
2323
type IntoIter = std::vec::IntoIter<Box<dyn $trait<T>>>;
2424

0 commit comments

Comments
 (0)