diff options
| author | Philipp A | 2018-11-19 21:26:38 +0100 |
|---|---|---|
| committer | Philipp A | 2018-11-19 21:26:38 +0100 |
| commit | de6c16c95806a5d26779c3bc96241dfcab1f18ec (patch) | |
| tree | 8283ca8371e547a6770180e918d910e2cc3cfc30 /src/document_tree/elements.rs | |
| parent | 4272b19a79f786c6121e6c18c5aa4da4a4b2e02a (diff) | |
| download | rust-rst-de6c16c95806a5d26779c3bc96241dfcab1f18ec.tar.bz2 | |
Make it compile again
Diffstat (limited to 'src/document_tree/elements.rs')
| -rw-r--r-- | src/document_tree/elements.rs | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/document_tree/elements.rs b/src/document_tree/elements.rs index 77efa34..681c52e 100644 --- a/src/document_tree/elements.rs +++ b/src/document_tree/elements.rs @@ -2,10 +2,7 @@ use url::Url; use serde::{ Serialize, Serializer, - ser::{ - SerializeSeq, - SerializeStruct, - }, + ser::{SerializeStruct}, }; use super::extra_attributes::{self,ExtraAttributes}; @@ -84,29 +81,24 @@ macro_rules! impl_serialize { ($name: ident, $extra: ident, $childtype: ident) => { impl Serialize for $name { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer { + #[allow(unused_mut)] let mut state = serializer.serialize_struct(stringify!($name), 3)?; // TODO: common attrs - impl_serialize_extra!($extra); - impl_serialize_children!($childtype, self, serializer); + impl_cond__! { $extra => + + } + impl_cond__! { $childtype => + state.serialize_field("children", self.children())?; + } state.end() } } }; } -macro_rules! impl_serialize_extra { - (__) => {}; - ($name: ident) => { - // TODO extra_attributes::$name - }; -} - -macro_rules! impl_serialize_children { - (__, $_: ident, $__: ident) => {}; - ($childtype: ident, $self: ident, $serializer: ident) => { - use serde::ser::SerializeStruct; - $serializer.serialize_field("children", $self.children()); - }; +macro_rules! impl_cond__ { + (__ => $($b:tt)*) => {}; + ($thing: ident => $($b:tt)*) => { $($b)* }; } macro_rules! impl_elem { |
