fn prev(&mut self) -> bool {
        let at_child_of_root = self.path.len() == 1;
        let at_first_child_of_root = at_child_of_root && self.path[0] == 0;
        let at_start = self.side == OutputSide::Start;

        let mut parent = Rc::clone(&self.root);
        let mut current_node = Rc::clone(&self.root);
        let mut last_index = 0;
        for index in self.path.iter() {
            let next = Rc::clone(&current_node[*index]);
            parent = current_node;
            current_node = next;
            last_index = *index;
        }

        // Check if we're at the first child of the root. If we're at the Start of it, OR it's
        // a collapsed / inlined container OR it's a primitive, then return false.
        if at_first_child_of_root {
            if at_start {
                return false;
            }

            match &current_node.value {
                JValue::Primitive(_) => return false,
                JValue::Container(_, cs) => {
                    if cs.get() != ContainerState::Expanded {
                        return false;
                    }
                }
            }
        }

        // Rules:
        // - If current node is primitive, go to prev sibling
        // - If current node is inlined/collapsed, go to prev sibling
        // - If on Start side of expanded container, go to prev sibling
        //
        // - If on End side of expanded container, go to last child
        //
        // - When going to prev sibling, if current node is the
        //   first child, go to the Start side of the parent.
        if current_node.is_expanded() && !at_start {
            // Go to last child current node if it's expanded.
            let last_child_index = current_node.len() - 1;
            self.path.push(last_child_index);
            self.side = if current_node[last_child_index].is_expanded() {
                OutputSide::End
            } else {
                OutputSide::Start
            };
        } else {
            // Otherwise go to previous sibling.
            if last_index == 0 {
                // But if already first sibling, go to Start of parent.
                self.path.pop();
                self.side = OutputSide::Start;
            } else {
                let i = self.path.len() - 1;
                self.path[i] -= 1;
                self.side = if parent[self.path[i]].is_expanded() {
                    OutputSide::End
                } else {
                    OutputSide::Start
                }
            }
        }

        true
    }
// Moves the line ref to the prev line in the output.
// Returns whether or not the line was already the first line in the structure.
//
// Rules:
// - If current node is primitive, go to prev sibling
// - If current node is inlined/collapsed, go to prev sibling
// - If on Start side of expanded container, go to prev sibling
// - If on End side of expanded container, go to last child
//
// - When going to prev sibling, if current node is the
//   first child, go to the Start side of the parent.
//
// - If already on the Start side of the root, don't do anything (but return false);
Moves the line ref to the prev line in the output.
Returns whether or not the line was already the first line in the structure.

If current node is primitive, go to prev sibling
If current node is inlined/collapsed, go to prev sibling
If on Start side of expanded container, go to prev sibling
If on End side of expanded container, go to last child

When going to prev sibling, if current node is the
first child, go to the Start side of the parent.

If already on the Start side of the root, don't do anything (but return false).
Moves the line ref to the prev line in the output . Returns whether or not the line was already the first line in the structure . If current node is primitive go to prev sibling If current node is inlined / collapsed go to prev sibling If on Start side of expanded container go to prev sibling If on End side of expanded container go to last child When going to prev sibling if current node is the first child go to the Start side of the parent . If already on the Start side of the root don ' t do anything ( but return false ) .
fn prev(&mut self) -> bool {
        let at_child_of_root = self.path.len() == 1;
        let at_first_child_of_root = at_child_of_root && self.path[0] == 0;
        let at_start = self.side == OutputSide::Start;
        let mut parent = Rc::clone(&self.root);
        let mut current_node = Rc::clone(&self.root);
        let mut last_index = 0;
        for index in self.path.iter() {
            let next = Rc::clone(&current_node[*index]);
            parent = current_node;
            current_node = next;
            last_index = *index;
        }
        // Check if we're at the first child of the root. If we're at the Start of it, OR it's
        // a collapsed / inlined container OR it's a primitive, then return false.
        if at_first_child_of_root {
            if at_start {
                return false;
            }
            match &current_node.value {
                JValue::Primitive(_) => return false,
                JValue::Container(_, cs) => {
                    if cs.get() != ContainerState::Expanded {
                        return false;
                    }
                }
            }
        }
        // Rules:
        // - If current node is primitive, go to prev sibling
        // - If current node is inlined/collapsed, go to prev sibling
        // - If on Start side of expanded container, go to prev sibling
        //
        // - If on End side of expanded container, go to last child
        //
        // - When going to prev sibling, if current node is the
        //   first child, go to the Start side of the parent.
        if current_node.is_expanded() && !at_start {
            // Go to last child current node if it's expanded.
            let last_child_index = current_node.len() - 1;
            self.path.push(last_child_index);
            self.side = if current_node[last_child_index].is_expanded() {
                OutputSide::End
            } else {
                OutputSide::Start
            };
        } else {
            // Otherwise go to previous sibling.
            if last_index == 0 {
                // But if already first sibling, go to Start of parent.
                self.path.pop();
                self.side = OutputSide::Start;
            } else {
                let i = self.path.len() - 1;
                self.path[i] -= 1;
                self.side = if parent[self.path[i]].is_expanded() {
                    OutputSide::End
                } else {
                    OutputSide::Start
                }
            }
        }
        true
    }
fn prev ( & mut self ) -> bool { let at_child_of_root = self . path . len ( ) == 1 ; let at_first_child_of_root = at_child_of_root && self . path [ 0 ] == 0 ; let at_start = self . side == OutputSide :: Start ; let mut parent = Rc :: clone ( & self . root ) ; let mut current_node = Rc :: clone ( & self . root ) ; let mut last_index = 0 ; for index in self . path . iter ( ) { let next = Rc :: clone ( & current_node [ * index ] ) ; parent = current_node ; current_node = next ; last_index = * index ; } // Check if we're at the first child of the root. If we're at the Start of it, OR it's // a collapsed / inlined container OR it's a primitive, then return false. if at_first_child_of_root { if at_start { return false ; } match & current_node . value { JValue :: Primitive ( _ ) => return false , JValue :: Container ( _ , cs ) => { if cs . get ( ) != ContainerState :: Expanded { return false ; } } } } // Rules: // - If current node is primitive, go to prev sibling // - If current node is inlined/collapsed, go to prev sibling // - If on Start side of expanded container, go to prev sibling // // - If on End side of expanded container, go to last child // // - When going to prev sibling, if current node is the //   first child, go to the Start side of the parent. if current_node . is_expanded ( ) && ! at_start { // Go to last child current node if it's expanded. let last_child_index = current_node . len ( ) - 1 ; self . path . push ( last_child_index ) ; self . side = if current_node [ last_child_index ] . is_expanded ( ) { OutputSide :: End } else { OutputSide :: Start } ; } else { // Otherwise go to previous sibling. if last_index == 0 { // But if already first sibling, go to Start of parent. self . path . pop ( ) ; self . side = OutputSide :: Start ; } else { let i = self . path . len ( ) - 1 ; self . path [ i ] -= 1 ; self . side = if parent [ self . path [ i ] ] . is_expanded ( ) { OutputSide :: End } else { OutputSide :: Start } } } true }
Moves the line ref to the prev line in the output.
Moves the line ref to the prev line in the output .
&mut self
&mut self