twrite_core/coordinates.rs
1/// A position within a text document.
2///
3/// The position is represented by a zero-based row and column.
4/// The exact meaning of `column` depends on the document's coordinate
5/// system, such as byte offset, character offset, or display column.
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub struct Point {
9 /// The zero-based row of the position.
10 pub row: usize,
11
12 /// The zero-based column of the position.
13 pub column: usize,
14}
15
16impl Point {
17 /// Creates a point at the given row and column.
18 pub const fn new(row: usize, column: usize) -> Self {
19 Self { row, column }
20 }
21
22 /// Creates a point at the beginning of the document.
23 pub const fn zero() -> Self {
24 Self { row: 0, column: 0 }
25 }
26}