Skip to main content

Node

Trait Node 

Source
pub(crate) trait Node: Clone {
    // Required methods
    fn adopt(&mut self, key: &str, source: &Self);
    fn adopt_shell(&mut self, key: &str, source: &Self);
    fn child(&self, key: &str) -> Option<&Self>;
    fn child_mut(&mut self, key: &str) -> Option<&mut Self>;
    fn is_container(&self) -> bool;
    fn keys(&self) -> impl Iterator<Item = &str> + '_;
    fn remove(&mut self, key: &str);

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A node of a format’s document tree that the merge can edit in place.

Required Methods§

Source

fn adopt(&mut self, key: &str, source: &Self)

Take the child key from source, replacing the existing child or appending. An existing child keeps its decor unless the desired child brings a comment of its own, which replaces the leading comment.

Source

fn adopt_shell(&mut self, key: &str, source: &Self)

Insert an empty container for the child key of source, with the decor and comment of that child.

Source

fn child(&self, key: &str) -> Option<&Self>

Source

fn child_mut(&mut self, key: &str) -> Option<&mut Self>

Source

fn is_container(&self) -> bool

Whether this node holds keyed children.

Source

fn keys(&self) -> impl Iterator<Item = &str> + '_

The child keys in order. Empty for leaves.

Source

fn remove(&mut self, key: &str)

Provided Methods§

Source

fn is_empty(&self) -> bool

Whether this node has no children.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Node for Item

Source§

fn is_container(&self) -> bool

Source§

fn keys(&self) -> impl Iterator<Item = &str> + '_

Source§

fn child(&self, key: &str) -> Option<&Self>

Source§

fn child_mut(&mut self, key: &str) -> Option<&mut Self>

Source§

fn adopt(&mut self, key: &str, source: &Self)

Source§

fn adopt_shell(&mut self, key: &str, source: &Self)

Source§

fn remove(&mut self, key: &str)

Implementors§