From cd1f20c1d269660c777d5aeb00ffa4bd5413ef2d Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Sat, 4 Mar 2023 11:27:31 +0000 Subject: [PATCH] Fix clib --- src/clib.rs | 6 +++--- src/system/mod.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/clib.rs b/src/clib.rs index 041823c..ceabd34 100644 --- a/src/clib.rs +++ b/src/clib.rs @@ -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) } diff --git a/src/system/mod.rs b/src/system/mod.rs index 1e5513e..cede115 100644 --- a/src/system/mod.rs +++ b/src/system/mod.rs @@ -14,12 +14,12 @@ pub trait GriddedPosition: Add + 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 } } } }