pub fn append_child(
        &mut self,
        parent: impl Into<Entity>,
        child: impl Into<Entity>,
    ) -> Result<Entity, NotFound> {
        let parent = parent.into();
        let child = child.into();

        if self.root.is_some() && parent == self.root.unwrap() && self.overlay.is_some() {
            // insert child to root before overlay
            let len = self.children.len();
            if let Some(p) = self.children.get_mut(&parent) {
                p.insert(len - 2, child);
            } else {
                return Err(NotFound::Parent(parent));
            }
        } else {
            if let Some(p) = self.children.get_mut(&parent) {
                p.push(child);
            } else {
                return Err(NotFound::Parent(parent));
            }
            self.parent.insert(child, Some(parent));
        }

        Ok(child)
    }
/// Appends a `child` entity to the given `parent` entity.
/// Raised `NotFound` error if the parent is not part of the tree.
Appends a `child` entity to the given `parent` entity.
Raised `NotFound` error if the parent is not part of the tree.
Appends a ` child ` entity to the given ` parent ` entity . Raised ` NotFound ` error if the parent is not part of the tree .
pub fn append_child(
        &mut self,
        parent: impl Into<Entity>,
        child: impl Into<Entity>,
    ) -> Result<Entity, NotFound> {
        let parent = parent.into();
        let child = child.into();
        if self.root.is_some() && parent == self.root.unwrap() && self.overlay.is_some() {
            // insert child to root before overlay
            let len = self.children.len();
            if let Some(p) = self.children.get_mut(&parent) {
                p.insert(len - 2, child);
            } else {
                return Err(NotFound::Parent(parent));
            }
        } else {
            if let Some(p) = self.children.get_mut(&parent) {
                p.push(child);
            } else {
                return Err(NotFound::Parent(parent));
            }
            self.parent.insert(child, Some(parent));
        }
        Ok(child)
    }
pub fn append_child ( & mut self , parent : impl Into < Entity > , child : impl Into < Entity > , ) -> Result < Entity , NotFound > { let parent = parent . into ( ) ; let child = child . into ( ) ; if self . root . is_some ( ) && parent == self . root . unwrap ( ) && self . overlay . is_some ( ) { // insert child to root before overlay let len = self . children . len ( ) ; if let Some ( p ) = self . children . get_mut ( & parent ) { p . insert ( len - 2 , child ) ; } else { return Err ( NotFound :: Parent ( parent ) ) ; } } else { if let Some ( p ) = self . children . get_mut ( & parent ) { p . push ( child ) ; } else { return Err ( NotFound :: Parent ( parent ) ) ; } self . parent . insert ( child , Some ( parent ) ) ; } Ok ( child ) }
Appends a `child` entity to the given `parent` entity.
Appends a ` child ` entity to the given ` parent ` entity .
&mut self
parent
impl Into<Entity>
child
impl Into<Entity>