Struct svg_simple_parser::Element [−][src]
pub struct Element<'a> {
pub ele_type: &'a str,
pub attributes: HashMap<String, &'a str>,
pub children: Vec<Element<'a>>,
}
Expand description
AST struct
ele_type
the type of the element
attributes
the attributes in the element
children
the children in the element
Fields
ele_type: &'a str
attributes: HashMap<String, &'a str>
children: Vec<Element<'a>>
Implementations
new a element without children
Example
use std::collections::HashMap;
Element::new(("rect",HashMap::from([("width".to_owned(), "100"),("height".to_owned(), "100")])));
new a element with children
Example
use std::collections::HashMap;
let child = Element::new(("rect",HashMap::from([("width".to_owned(), "100"),("height".to_owned(), "100")])));
Element::new_width_children(("rect",HashMap::from([("width".to_owned(), "100"),("height".to_owned(), "100")]),vec![child]));
add a element to the children of the element.
Example
use std::collections::HashMap;
let parent = Element::new(("rect",HashMap::from([("width".to_owned(), "100"),("height".to_owned(), "100")])));
let child = Element::new(("rect",HashMap::from([("width".to_owned(), "100"),("height".to_owned(), "100")])));
parent.add(child)
add a list of element to the children of the element.
Example
use std::collections::HashMap;
let parent = Element::new(("rect",HashMap::from([("width".to_owned(), "100"),("height".to_owned(), "100")])));
let child = Element::new(("rect",HashMap::from([("width".to_owned(), "100"),("height".to_owned(), "100")])));
parent.add_children(vec![child])