fn consider_split<Id: Hash + Clone + Eq + Debug>(
    tree: &mut Tree<Id>,
    segment: NodeId,
) -> (NodeId, NodeId) {
    if tree.nodes[&segment].segment_is_container() {
        // abort if this is off the edge of a string
        return (segment, segment);
    }
    let ids = tree.nodes[&segment].segment_ids_mut().unwrap();
    if ids.len() <= SPLIT_LEN {
        return (segment, segment);
    }
    // the first index of the second segment. need to do this stuff to make sure we split
    // along a codepoint boundary
    let split_start_vec = ids.len() / 2;
    let new_node_id = insert_segment(tree, segment, split_start_vec);
    let (left, _) = consider_split(tree, segment);
    let (_, right) = consider_split(tree, new_node_id);
    (left, right)
}
/// If `segment` is greater than `SPLIT_LEN`, we'll split it into two pieces. This recurses on
/// the children, further splitting them if they're still too long. Returns the leftmost and
/// rightmost of the new segments; if no split occured, these will both still be `segment`.
// TODO this could probably be sped up to instantly segment a very long node into `n` children.
If `segment` is greater than `SPLIT_LEN`, we'll split it into two pieces. This recurses on
the children, further splitting them if they're still too long. Returns the leftmost and
rightmost of the new segments; if no split occured, these will both still be `segment`.
TODO this could probably be sped up to instantly segment a very long node into `n` children.
If ` segment ` is greater than ` SPLIT_LEN ` we ' ll split it into two pieces . This recurses on the children further splitting them if they ' re still too long . Returns the leftmost and rightmost of the new segments ; if no split occured these will both still be ` segment ` . TODO this could probably be sped up to instantly segment a very long node into ` n ` children .
fn consider_split<Id: Hash + Clone + Eq + Debug>(
    tree: &mut Tree<Id>,
    segment: NodeId,
) -> (NodeId, NodeId) {
    if tree.nodes[&segment].segment_is_container() {
        // abort if this is off the edge of a string
        return (segment, segment);
    }
    let ids = tree.nodes[&segment].segment_ids_mut().unwrap();
    if ids.len() <= SPLIT_LEN {
        return (segment, segment);
    }
    // the first index of the second segment. need to do this stuff to make sure we split
    // along a codepoint boundary
    let split_start_vec = ids.len() / 2;
    let new_node_id = insert_segment(tree, segment, split_start_vec);
    let (left, _) = consider_split(tree, segment);
    let (_, right) = consider_split(tree, new_node_id);
    (left, right)
}
fn consider_split < Id : Hash + Clone + Eq + Debug > ( tree : & mut Tree < Id > , segment : NodeId , ) -> ( NodeId , NodeId ) { if tree . nodes [ & segment ] . segment_is_container ( ) { // abort if this is off the edge of a string return ( segment , segment ) ; } let ids = tree . nodes [ & segment ] . segment_ids_mut ( ) . unwrap ( ) ; if ids . len ( ) <= SPLIT_LEN { return ( segment , segment ) ; } // the first index of the second segment. need to do this stuff to make sure we split // along a codepoint boundary let split_start_vec = ids . len ( ) / 2 ; let new_node_id = insert_segment ( tree , segment , split_start_vec ) ; let ( left , _ ) = consider_split ( tree , segment ) ; let ( _ , right ) = consider_split ( tree , new_node_id ) ; ( left , right ) }
If `segment` is greater than `SPLIT_LEN`, we'll split it into two pieces.
If ` segment ` is greater than ` SPLIT_LEN ` we ' ll split it into two pieces .
tree
&mut Tree<Id>
segment
NodeId