rustidy_util/
ast_range.rs1use crate::AstPos;
5
6#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)]
8#[derive(serde::Serialize, serde::Deserialize)]
9pub struct AstRange {
10 pub start: AstPos,
11 pub end: AstPos,
12}
13
14impl AstRange {
15 #[must_use]
17 pub const fn new(start: AstPos, end: AstPos) -> Self {
18 Self { start, end }
19 }
20
21 #[must_use]
23 pub const fn len(&self) -> usize {
24 self.end.0 - self.start.0
25 }
26
27 #[must_use]
29 pub const fn is_empty(&self) -> bool {
30 self.len() == 0
31 }
32}