diff options
| author | Phil Schaf | 2015-11-14 22:18:58 +0100 |
|---|---|---|
| committer | Phil Schaf | 2015-11-14 22:18:58 +0100 |
| commit | 11d453f354c3bfd8f2c2f755c0246f3c2f526179 (patch) | |
| tree | 3cada607217cb784751e0252cb7e9a00b5bc3e29 /src/document_tree/element_categories.rs | |
| parent | d3c3b98b43713a66111994c81bbf5c12776ad39f (diff) | |
| download | rust-rst-11d453f354c3bfd8f2c2f755c0246f3c2f526179.tar.bz2 | |
added a append_children function
Diffstat (limited to 'src/document_tree/element_categories.rs')
| -rw-r--r-- | src/document_tree/element_categories.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/document_tree/element_categories.rs b/src/document_tree/element_categories.rs index 17bc01a..d8024ad 100644 --- a/src/document_tree/element_categories.rs +++ b/src/document_tree/element_categories.rs @@ -6,6 +6,13 @@ pub trait HasChildren<C> { fn append_child<R: Into<C>>(&mut self, child: R) { self.children_mut().push(child.into()); } + fn append_children<R: Into<C> + Clone>(&mut self, more: &[R]) { + let mut children = self.children_mut(); + children.reserve(more.len()); + for child in more { + children.push(child.clone().into()); + } + } } macro_rules! synonymous_enum {( $name:ident { $( $entry:ident ),* } ) => ( |
