[][src]Trait deep_safe_drop::DeepSafeDrop

pub trait DeepSafeDrop<Link> {
    fn take_first_child(&mut self) -> Option<Link>;
fn replace_first_child_with_parent(
        &mut self,
        parent: Link
    ) -> ReplacedFirstChild<Link>;
fn take_next_child(&mut self) -> Option<Link>; }

Implement this for your tree node type, with Link as your tree link type that dereferences to your node type.

The Link type may be the same as the Self type, when possible, which might be convenient. Or, they can be different.

Many Self types should be able to implement these methods without needing any extra state beyond their normal state.

Required methods

fn take_first_child(&mut self) -> Option<Link>

Supply the first child and replace the link to it with a non-link, if the current state of self has at least one child.

fn replace_first_child_with_parent(
    &mut self,
    parent: Link
) -> ReplacedFirstChild<Link>

Supply the first child and replace the link to it with a given replacement that links to the parent of self, if the current state of self has at least one child.

fn take_next_child(&mut self) -> Option<Link>

Supply the next child and replace the link to it with a non-link, if the current state of self has another child that has not been supplied yet.

Loading content...

Implementors

Loading content...