diff options
| author | Philipp A | 2019-12-08 20:24:47 +0100 | 
|---|---|---|
| committer | Philipp A | 2019-12-08 20:24:47 +0100 | 
| commit | 1f95ebcc0e4e1393531e3d20e02d750ba0b476d6 (patch) | |
| tree | b3d65cef9bcee19325f74c97a5e337956020adee /src/document_tree/elements.rs | |
| parent | 008b29ea8a15b28df5b84efaf124bd79aa1f8fa3 (diff) | |
| download | rust-rst-1f95ebcc0e4e1393531e3d20e02d750ba0b476d6.tar.bz2 | |
Convenience with_extra_and_children
Diffstat (limited to 'src/document_tree/elements.rs')
| -rw-r--r-- | src/document_tree/elements.rs | 13 | 
1 files changed, 13 insertions, 0 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 { $( | 
