diff --git a/sbp/src/utils.rs b/sbp/src/utils.rs index 9e5aaaf..06e49e7 100644 --- a/sbp/src/utils.rs +++ b/sbp/src/utils.rs @@ -21,6 +21,22 @@ pub struct Direction { } impl Direction { + pub fn as_ref(&self) -> Direction<&T> { + Direction { + north: &self.north, + south: &self.south, + west: &self.west, + east: &self.east, + } + } + pub fn as_mut(&mut self) -> Direction<&mut T> { + Direction { + north: &mut self.north, + south: &mut self.south, + west: &mut self.west, + east: &mut self.east, + } + } pub fn map(self, f: impl Fn(T) -> U) -> Direction { Direction { north: f(self.north),