Skip to content

Commit 75f606a

Browse files
committed
reduce Location size to practical small one
1 parent d446a5a commit 75f606a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bytecode/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use std::{collections::BTreeSet, fmt, hash};
1515
/// Sourcecode location.
1616
#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)]
1717
pub struct Location {
18-
row: usize,
19-
column: usize,
18+
row: u32,
19+
column: u32,
2020
}
2121

2222
impl Location {
@@ -28,17 +28,19 @@ impl Location {
2828
/// let loc = Location::new(10, 10);
2929
/// ```
3030
pub fn new(row: usize, column: usize) -> Self {
31+
let row = row.try_into().expect("Location::row over u32");
32+
let column = column.try_into().expect("Location::column over u32");
3133
Location { row, column }
3234
}
3335

3436
/// Current row
3537
pub fn row(&self) -> usize {
36-
self.row
38+
self.row as usize
3739
}
3840

3941
/// Current column
4042
pub fn column(&self) -> usize {
41-
self.column
43+
self.column as usize
4244
}
4345
}
4446

0 commit comments

Comments
 (0)