pub fn shrink_to_fit(&mut self) {
        let mut node_stack = Vec::new();
        let mut builder = RopeBuilder::new();

        node_stack.push(self.root.clone());
        *self = Rope::new();

        loop {
            if node_stack.is_empty() {
                break;
            }

            if node_stack.last().unwrap().is_leaf() {
                builder.append(node_stack.last().unwrap().leaf_text());
                node_stack.pop();
            } else if node_stack.last().unwrap().child_count() == 0 {
                node_stack.pop();
            } else {
                let (_, next_node) = Arc::make_mut(node_stack.last_mut().unwrap())
                    .children_mut()
                    .remove(0);
                node_stack.push(next_node);
            }
        }

        *self = builder.finish();
    }
/// Shrinks the `Rope`'s capacity to the minimum possible.
///
/// This will rarely result in `capacity() == len_bytes()`.  `Rope`
/// stores text in a sequence of fixed-capacity chunks, so an exact fit
/// only happens for texts that are both a precise multiple of that
/// capacity _and_ have code point boundaries that line up exactly with
/// the capacity boundaries.
///
/// After calling this, the difference between `capacity()` and
/// `len_bytes()` is typically under 1KB per megabyte of text in the
/// `Rope`.
///
/// **NOTE:** calling this on a `Rope` clone causes it to stop sharing
/// all data with its other clones.  In such cases you will very likely
/// be _increasing_ total memory usage despite shrinking the `Rope`'s
/// capacity.
///
/// Runs in O(N) time, and uses O(log N) additional space during
/// shrinking.
Shrinks the `Rope`'s capacity to the minimum possible.
This will rarely result in `capacity() == len_bytes()`.  `Rope`
stores text in a sequence of fixed-capacity chunks, so an exact fit
only happens for texts that are both a precise multiple of that
capacity _and_ have code point boundaries that line up exactly with
the capacity boundaries.



calling this on a `Rope` clone causes it to stop sharing
all data with its other clones.  In such cases you will very likely
be _increasing_ total memory usage despite shrinking the `Rope`'s
capacity.

Runs in O(N) time, and uses O(log N) additional space during
shrinking.
Shrinks the ` Rope ` ' s capacity to the minimum possible . This will rarely result in ` capacity () == len_bytes () ` . ` Rope ` stores text in a sequence of fixed - capacity chunks so an exact fit only happens for texts that are both a precise multiple of that capacity _and_ have code point boundaries that line up exactly with the capacity boundaries . calling this on a ` Rope ` clone causes it to stop sharing all data with its other clones . In such cases you will very likely be _increasing_ total memory usage despite shrinking the ` Rope ` ' s capacity . Runs in O ( N ) time and uses O ( log N ) additional space during shrinking .
pub fn shrink_to_fit(&mut self) {
        let mut node_stack = Vec::new();
        let mut builder = RopeBuilder::new();
        node_stack.push(self.root.clone());
        *self = Rope::new();
        loop {
            if node_stack.is_empty() {
                break;
            }
            if node_stack.last().unwrap().is_leaf() {
                builder.append(node_stack.last().unwrap().leaf_text());
                node_stack.pop();
            } else if node_stack.last().unwrap().child_count() == 0 {
                node_stack.pop();
            } else {
                let (_, next_node) = Arc::make_mut(node_stack.last_mut().unwrap())
                    .children_mut()
                    .remove(0);
                node_stack.push(next_node);
            }
        }
        *self = builder.finish();
    }
pub fn shrink_to_fit ( & mut self ) { let mut node_stack = Vec :: new ( ) ; let mut builder = RopeBuilder :: new ( ) ; node_stack . push ( self . root . clone ( ) ) ; * self = Rope :: new ( ) ; loop { if node_stack . is_empty ( ) { break ; } if node_stack . last ( ) . unwrap ( ) . is_leaf ( ) { builder . append ( node_stack . last ( ) . unwrap ( ) . leaf_text ( ) ) ; node_stack . pop ( ) ; } else if node_stack . last ( ) . unwrap ( ) . child_count ( ) == 0 { node_stack . pop ( ) ; } else { let ( _ , next_node ) = Arc :: make_mut ( node_stack . last_mut ( ) . unwrap ( ) ) . children_mut ( ) . remove ( 0 ) ; node_stack . push ( next_node ) ; } } * self = builder . finish ( ) ; }
Shrinks the `Rope`'s capacity to the minimum possible.
Shrinks the ` Rope ` ' s capacity to the minimum possible .
&mut self