moonlander_gp

Function clone_or_replace

Source
pub fn clone_or_replace<T: AstNode + Clone>(
    child: &T,
    old_child: &dyn AstNode,
    new_child: &mut Option<Box<dyn AstNode>>,
) -> Box<T>
Expand description

Helper function for use inside replace_children().

Call this for every child node in replace_children(). The new_child is a &mut Option<> so that we can be sure we consume it exactly once.