pub fn delete_cursor(&mut self, count: usize) -> EditResult<Node::Class> {
        self.perform_edit(
            |this: &mut Self,
             parent_and_index: Option<(&'arena Node, usize)>,
             cursor: &'arena Node| {
                // Find (and cache) the parent of the cursor.  If the parent of the cursor doesn't
                // exist, the cursor must be the root and we can't delete the root.
                let (parent, cursor_index) = parent_and_index.ok_or(EditErr::DeletingRoot)?;
                // Cache the name of the cursor **before** it gets deleted
                let deleted_node_name = cursor.display_name();

                let mut cloned_parent = parent.clone();
                // Delete the node under the cursor `count` many times, or until we run off the end
                // of the children
                for _ in 0..count {
                    let res = cloned_parent.delete_child(cursor_index);
                    // If we've run off the end of the children, this is not an error - we just
                    // break the loop and stop
                    if let Err(ast::DeleteError::IndexOutOfRange { .. }) = res {
                        break;
                    }
                    // Any other errors are hard errors, so we should stop in those cases
                    res?;
                }

                let new_parents_child_count = cloned_parent.children().len();
                if new_parents_child_count == 0 {
                    // If we remove the only child of a node then we move the cursor up
                    this.current_cursor_path.pop();
                } else if cursor_index == new_parents_child_count {
                    // If we deleted the last child of a node (and this isn't the last child), we
                    // move the cursor back by one.  We can unwrap here because we know we aren't
                    // removing the root
                    *this.current_cursor_path.last_mut().unwrap() -= 1;
                }

                Ok((
                    cloned_parent,
                    EditLocation::Parent,
                    EditSuccess::Delete {
                        name: deleted_node_name,
                    },
                ))
            },
        )
    }
/// Deletes up to `count` nodes after the cursor
Deletes up to `count` nodes after the cursor
Deletes up to ` count ` nodes after the cursor
pub fn delete_cursor(&mut self, count: usize) -> EditResult<Node::Class> {
        self.perform_edit(
            |this: &mut Self,
             parent_and_index: Option<(&'arena Node, usize)>,
             cursor: &'arena Node| {
                // Find (and cache) the parent of the cursor.  If the parent of the cursor doesn't
                // exist, the cursor must be the root and we can't delete the root.
                let (parent, cursor_index) = parent_and_index.ok_or(EditErr::DeletingRoot)?;
                // Cache the name of the cursor **before** it gets deleted
                let deleted_node_name = cursor.display_name();
                let mut cloned_parent = parent.clone();
                // Delete the node under the cursor `count` many times, or until we run off the end
                // of the children
                for _ in 0..count {
                    let res = cloned_parent.delete_child(cursor_index);
                    // If we've run off the end of the children, this is not an error - we just
                    // break the loop and stop
                    if let Err(ast::DeleteError::IndexOutOfRange { .. }) = res {
                        break;
                    }
                    // Any other errors are hard errors, so we should stop in those cases
                    res?;
                }
                let new_parents_child_count = cloned_parent.children().len();
                if new_parents_child_count == 0 {
                    // If we remove the only child of a node then we move the cursor up
                    this.current_cursor_path.pop();
                } else if cursor_index == new_parents_child_count {
                    // If we deleted the last child of a node (and this isn't the last child), we
                    // move the cursor back by one.  We can unwrap here because we know we aren't
                    // removing the root
                    *this.current_cursor_path.last_mut().unwrap() -= 1;
                }
                Ok((
                    cloned_parent,
                    EditLocation::Parent,
                    EditSuccess::Delete {
                        name: deleted_node_name,
                    },
                ))
            },
        )
    }
pub fn delete_cursor ( & mut self , count : usize ) -> EditResult < Node :: Class > { self . perform_edit ( | this : & mut Self , parent_and_index : Option < ( & ' arena Node , usize ) > , cursor : & ' arena Node | { // Find (and cache) the parent of the cursor.  If the parent of the cursor doesn't // exist, the cursor must be the root and we can't delete the root. let ( parent , cursor_index ) = parent_and_index . ok_or ( EditErr :: DeletingRoot ) ? ; // Cache the name of the cursor **before** it gets deleted let deleted_node_name = cursor . display_name ( ) ; let mut cloned_parent = parent . clone ( ) ; // Delete the node under the cursor `count` many times, or until we run off the end // of the children for _ in 0 .. count { let res = cloned_parent . delete_child ( cursor_index ) ; // If we've run off the end of the children, this is not an error - we just // break the loop and stop if let Err ( ast :: DeleteError :: IndexOutOfRange { .. } ) = res { break ; } // Any other errors are hard errors, so we should stop in those cases res ? ; } let new_parents_child_count = cloned_parent . children ( ) . len ( ) ; if new_parents_child_count == 0 { // If we remove the only child of a node then we move the cursor up this . current_cursor_path . pop ( ) ; } else if cursor_index == new_parents_child_count { // If we deleted the last child of a node (and this isn't the last child), we // move the cursor back by one.  We can unwrap here because we know we aren't // removing the root * this . current_cursor_path . last_mut ( ) . unwrap ( ) -= 1 ; } Ok ( ( cloned_parent , EditLocation :: Parent , EditSuccess :: Delete { name : deleted_node_name , } , ) ) } , ) }
Deletes up to `count` nodes after the cursor
Deletes up to ` count ` nodes after the cursor
&mut self
count
usize
&mut self
count
usize