We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Position
1 parent f6adfa3 commit a821a08Copy full SHA for a821a08
2 files changed
rusty_common/src/position.rs
@@ -12,13 +12,12 @@ impl Position {
12
Self { row, col }
13
}
14
15
- pub fn inc_col(&mut self) {
16
- self.col += 1
+ pub fn inc_col(self) -> Self {
+ Self::new(self.row, self.col + 1)
17
18
19
- pub fn inc_row(&mut self) {
20
- self.row += 1;
21
- self.col = 1;
+ pub fn inc_row(self) -> Self {
+ Self::new(self.row + 1, 1)
22
23
24
pub fn start() -> Self {
rusty_parser/src/pc/string_view.rs
@@ -17,9 +17,8 @@ impl StringView {
if self.row_col.is_empty() {
Position::start()
} else {
- let mut pos = self.row_col[self.row_col.len() - 1];
- pos.inc_col();
- pos
+ let final_pos = self.row_col[self.row_col.len() - 1];
+ final_pos.inc_col()
25
0 commit comments