Enum html_editor::Node
source · [−]pub enum Node {
Element {
name: String,
attrs: Vec<(String, String)>,
children: Vec<Node>,
},
Text(String),
Comment(String),
Doctype,
}Expand description
Basic node of dom
Variants
Element
Text(String)
Comment(String)
Doctype
Implementations
sourceimpl Node
impl Node
sourcepub fn is_element(&self) -> bool
pub fn is_element(&self) -> bool
Check if it is an element node.
use html_editor::Node;
assert_eq!(Node::new_element("div", vec![("id", "app")], vec![]).is_element(), true);
assert_eq!(Node::Text("Lorem Ipsum".to_string()).is_element(), false);sourcepub fn into_element(self) -> Element
pub fn into_element(self) -> Element
Convert the node into an element.
Note: The program will panic if it fails to convert. So take care to use this method unless you are sure.
use html_editor::{Node, Element};
let a: Node = Node::new_element("div", vec![("id", "app")], vec![]);
let a: Element = a.into_element();
let b: Node = Node::Text("hello".to_string());
// This will panic at 'Text("hello") is not an element'
// let b: Element = a.into_element();Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnwindSafe for Node
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more