pub(crate) fn cursor_at_char(&self, char_pos: usize, stick_end: bool) -> RopeCursor {
        assert!(char_pos <= self.len_chars());

        let mut e: *const Node = &self.head;
        let mut height = self.head.height as usize - 1;
        
        let mut offset = char_pos; // How many more chars to skip

        let mut iter = RopeCursor([SkipEntry::new(); MAX_HEIGHT+1]);

        loop { // while height >= 0
            let en = unsafe { &*e };
            let next = en.nexts()[height];
            let skip = next.skip_chars;
            if offset > skip || (!stick_end && offset == skip && !next.node.is_null()) {
                // Go right.
                assert!(e == &self.head || !en.str.is_empty());
                offset -= skip;
                e = next.node;
                assert!(!e.is_null(), "Internal constraint violation: Reached rope end prematurely");
            } else {
                // Record this and go down.
                iter.0[height] = SkipEntry {
                    skip_chars: offset,
                    node: e as *mut Node, // This is pretty gross
                };

                if height == 0 { break; } else { height -= 1; }
            }
        };

        assert!(offset <= NODE_STR_SIZE);
        iter
    }
// Internal function for navigating to a particular character offset in the rope.  The function
// returns the list of nodes which point past the position, as well as offsets of how far into
// their character lists the specified characters are.
Internal function for navigating to a particular character offset in the rope.  The function
returns the list of nodes which point past the position, as well as offsets of how far into
their character lists the specified characters are.
Internal function for navigating to a particular character offset in the rope . The function returns the list of nodes which point past the position as well as offsets of how far into their character lists the specified characters are .
pub(crate) fn cursor_at_char(&self, char_pos: usize, stick_end: bool) -> RopeCursor {
        assert!(char_pos <= self.len_chars());
        let mut e: *const Node = &self.head;
        let mut height = self.head.height as usize - 1;
        let mut offset = char_pos; // How many more chars to skip
        let mut iter = RopeCursor([SkipEntry::new(); MAX_HEIGHT+1]);
        loop { // while height >= 0
            let en = unsafe { &*e };
            let next = en.nexts()[height];
            let skip = next.skip_chars;
            if offset > skip || (!stick_end && offset == skip && !next.node.is_null()) {
                // Go right.
                assert!(e == &self.head || !en.str.is_empty());
                offset -= skip;
                e = next.node;
                assert!(!e.is_null(), "Internal constraint violation: Reached rope end prematurely");
            } else {
                // Record this and go down.
                iter.0[height] = SkipEntry {
                    skip_chars: offset,
                    node: e as *mut Node, // This is pretty gross
                };
                if height == 0 { break; } else { height -= 1; }
            }
        };
        assert!(offset <= NODE_STR_SIZE);
        iter
    }
pub ( crate ) fn cursor_at_char ( & self , char_pos : usize , stick_end : bool ) -> RopeCursor { assert ! ( char_pos self len_chars ( ) ) ; let mut e : * const Node = & self . head ; let mut height = self . head . height as usize - 1 ; let mut offset = char_pos ; // How many more chars to skip let mut iter = RopeCursor ( [ SkipEntry :: new ( ) ; MAX_HEIGHT + 1 ] ) ; loop { // while height >= 0 let en = unsafe { & * e } ; let next = en . nexts ( ) [ height ] ; let skip = next . skip_chars ; if offset > skip || ( ! stick_end && offset == skip && ! next . node . is_null ( ) ) { // Go right. assert ! ( e self head en str is_empty ( ) ) ; offset -= skip ; e = next . node ; assert ! ( e is_null ( ) " " ) ; } else { // Record this and go down. iter . 0 [ height ] = SkipEntry { skip_chars : offset , node : e as * mut Node , // This is pretty gross } ; if height == 0 { break ; } else { height -= 1 ; } } } ; assert ! ( offset NODE_STR_SIZE ) ; iter }
Internal function for navigating to a particular character offset in the rope.
Internal function for navigating to a particular character offset in the rope .
&self
char_pos
usize
stick_end
bool