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 strattributes: 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])

Trait Implementations

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.