Skip to content

Commit 787b88c

Browse files
authored
Merge pull request #3997 from reese/reese-rust-expose-start-offset
[rust] Expose `start` offsets for `Location`
2 parents aafb1e9 + 572f35f commit 787b88c

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

rust/ruby-prism/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ mod tests {
465465

466466
assert_eq!(slice, "222");
467467
assert_eq!(6, location.start);
468+
assert_eq!(location.start, location.start());
468469
assert_eq!(9, location.end());
469470

470471
let recv_loc = plus.receiver().unwrap().location();

rust/ruby-prism/src/parse_result/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ impl<'pr> Location<'pr> {
4444
}
4545
}
4646

47+
/// Returns the start offset from the beginning of the parsed source.
48+
#[must_use]
49+
pub const fn start(&self) -> u32 {
50+
self.start
51+
}
52+
4753
/// Returns the end offset from the beginning of the parsed source.
4854
#[must_use]
4955
pub const fn end(&self) -> u32 {

0 commit comments

Comments
 (0)