Skip to content

Commit a821a08

Browse files
committed
chore: Removed mut methods of Position
1 parent f6adfa3 commit a821a08

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

rusty_common/src/position.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ impl Position {
1212
Self { row, col }
1313
}
1414

15-
pub fn inc_col(&mut self) {
16-
self.col += 1
15+
pub fn inc_col(self) -> Self {
16+
Self::new(self.row, self.col + 1)
1717
}
1818

19-
pub fn inc_row(&mut self) {
20-
self.row += 1;
21-
self.col = 1;
19+
pub fn inc_row(self) -> Self {
20+
Self::new(self.row + 1, 1)
2221
}
2322

2423
pub fn start() -> Self {

rusty_parser/src/pc/string_view.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ impl StringView {
1717
if self.row_col.is_empty() {
1818
Position::start()
1919
} else {
20-
let mut pos = self.row_col[self.row_col.len() - 1];
21-
pos.inc_col();
22-
pos
20+
let final_pos = self.row_col[self.row_col.len() - 1];
21+
final_pos.inc_col()
2322
}
2423
}
2524
}

0 commit comments

Comments
 (0)