This commit is contained in:
Joshua Coles 2023-03-04 11:27:31 +00:00
parent 0d972dc76a
commit cd1f20c1d2
2 changed files with 6 additions and 6 deletions

View File

@ -17,12 +17,12 @@ pub extern "C" fn storage_new(grid_size: u32) -> &'static mut CStorage {
#[no_mangle]
pub extern "C" fn storage_at(storage: &CStorage, i: i32, j: i32) -> bool {
storage.0.at(&Position(i, j))
storage.0.at(&Position { x: i, y: j })
}
#[no_mangle]
pub extern "C" fn storage_deposit(storage: &mut CStorage, i: i32, j: i32, val: u8) {
storage.0.write(&Position(i, j), val == 1);
storage.0.write(&Position { x: i, y: j }, val == 1);
}
#[no_mangle]
@ -66,7 +66,7 @@ mod test {
let sign = if sign == 0 { 1 } else { -1 };
// HACK: Our conventin and the MVA are different, since we are trying to strangle fig this, quick hack.
let offset = Position::in_direction(dim, sign);
let next = Position(i, j) + offset;
let next = Position { x: i, y: j } + offset;
CPosition(next.0, next.1)
}

View File

@ -14,12 +14,12 @@ pub trait GriddedPosition: Add<Output=Self> + Serialize + Clone {
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Position {
x: i32,
y: i32,
pub x: i32,
pub y: i32,
}
impl Position {
fn in_direction(direction: u32, value: i32) -> Self {
pub fn in_direction(direction: u32, value: i32) -> Self {
if direction == 0 { Position { x: value, y: 0 } } else { Position { x: 0, y: value } }
}
}