peace-table 0.1.0

A UTF-8, char oriented, text editing optimized, Piece Table implementation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::Buffer;

#[derive(Debug)]
pub(crate) struct Piece {
    /// Which [`Buffer`] is this piece referencing.
    pub(crate) buffer: Buffer,
    /// Start index in the buffer.
    pub(crate) start: usize,

    pub(crate) len_bytes: usize,
    pub(crate) len_chars: usize,
}

impl Piece {
    pub(crate) fn byte_range(&self) -> std::ops::Range<usize> {
        self.start..self.start + self.len_bytes
    }
}