text_buffer/
position.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::metric::Metric;

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct Position {
    metric: Metric,
}

impl Position {
    pub(crate) fn new(metric: Metric) -> Self {
        Self { metric }
    }

    #[must_use]
    pub fn chars(&self) -> usize {
        self.metric.chars
    }

    #[must_use]
    pub fn bytes(&self) -> usize {
        self.metric.bytes
    }
}