Repository: helix-editor/helix
File: helix-stdx/src/rope.rs (Rust)

Code before:
    fn grapheme_indices_at(self, byte_idx: usize) -> RopeGraphemeIndices<'a> {
        RopeGraphemeIndices {
            front_offset: byte_idx,
            iter: self.graphemes_at(byte_idx),
            is_reversed: false,
        }
    }

    fn nth_next_grapheme_boundary(self, mut byte_idx: usize, n: usize) -> usize {
        // Bounds check
        debug_assert!(byte_idx <= self.len_bytes());

        byte_idx = self.floor_char_boundary(byte_idx);

        // Get the chunk with our byte index in it.
        let (mut chunk, mut chunk_byte_idx, _, _) = self.chunk_at_byte(byte_idx);

        // Set up the grapheme cursor.
        let mut gc = GraphemeCursor::new(byte_idx, self.len_bytes(), true);

        // Find the nth next grapheme cluster boundary.
        for _ in 0..n {
            loop {
                match gc.next_boundary(chunk, chunk_byte_idx) {
                    Ok(None) => return self.len_bytes(),
                    Ok(Some(n)) => {
                        byte_idx = n;
                        break;
                    }
                    Err(GraphemeIncomplete::NextChunk) => {
                        chunk_byte_idx += chunk.len();
                        let (a, _, _, _) = self.chunk_at_byte(chunk_byte_idx);
                        chunk = a;
                    }
                    Err(GraphemeIncomplete::PreContext(n)) => {
                        let ctx_chunk = self.chunk_at_byte(n - 1).0;
                        gc.provide_context(ctx_chunk, n - ctx_chunk.len());
                    }
                    _ => unreachable!(),
                }
            }
        }

        byte_idx
    }

    fn nth_prev_grapheme_boundary(self, mut byte_idx: usize, n: usize) -> usize {
        // Bounds check
        debug_assert!(byte_idx <= self.len_bytes());

        byte_idx = self.ceil_char_boundary(byte_idx);

Review comment (suggestion):
it is a bit confusing to shadow the argument n. 

I suggest using `b` or `next_byte_index`.

Same for prev

Code after:
    }

    fn graphemes_at(self, byte_idx: usize) -> RopeGraphemes<'a> {
        // Bounds check
        assert!(byte_idx <= self.len_bytes());

        let (mut chunks, chunk_byte_idx, _, _) = self.chunks_at_byte(byte_idx);
        let current_chunk = chunks.next().unwrap_or("");

        RopeGraphemes {
            text: self,
            chunks,
            current_chunk,
            chunk_byte_idx,
            cursor: GraphemeCursor::new(byte_idx, self.len_bytes(), true),
            is_reversed: false,
        }
    }

    fn grapheme_indices_at(self, byte_idx: usize) -> RopeGraphemeIndices<'a> {
        // Bounds check
        assert!(byte_idx <= self.len_bytes());
        RopeGraphemeIndices {
            front_offset: byte_idx,
            iter: self.graphemes_at(byte_idx),
            is_reversed: false,
        }
    }

    fn nth_next_grapheme_boundary(self, mut byte_idx: usize, n: usize) -> usize {
        // Bounds check
        assert!(byte_idx <= self.len_bytes());

        byte_idx = self.floor_char_boundary(byte_idx);

        // Get the chunk with our byte index in it.
        let (mut chunk, mut chunk_byte_idx, _, _) = self.chunk_at_byte(byte_idx);

        // Set up the grapheme cursor.
        let mut gc = GraphemeCursor::new(byte_idx, self.len_bytes(), true);

        // Find the nth next grapheme cluster boundary.
        for _ in 0..n {
            loop {
                match gc.next_boundary(chunk, chunk_byte_idx) {
                    Ok(None) => return self.len_bytes(),
                    Ok(Some(boundary)) => {
                        byte_idx = boundary;
                        break;
                    }
                    Err(GraphemeIncomplete::NextChunk) => {