From 83cbb0094eac0f1300dff48e9e0dbd8f1960c3f6 Mon Sep 17 00:00:00 2001 From: Volodymyr Patuta <6977238-fiplox@users.noreply.gitlab.com> Date: Wed, 28 Oct 2020 21:38:30 +0100 Subject: [PATCH] pub-issues --- src/robot.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/robot.rs b/src/robot.rs index bedefa3..a06e218 100644 --- a/src/robot.rs +++ b/src/robot.rs @@ -1,19 +1,19 @@ /// A Robot *aka droid* is represented here. /// Each robot must have a unique id. pub struct Robot { - id: u32, - o: Orientation, - p: Position, + pub id: u32, + pub o: Orientation, + pub p: Position, i: Vec, } impl Robot { /// Create new `Robot` with given id, `Orientation`, `Position` and instructions. - fn new(id: u32, o: Orientation, p: Position, i: Vec) -> Robot { + pub fn new(id: u32, o: Orientation, p: Position, i: Vec) -> Robot { Robot { id, o, p, i } } /// Apply given instruction to a `Robot`. - fn execute_instruction(&mut self) { + pub fn execute_instruction(&mut self) { match self.i.pop() { Some(instruction) => match instruction { 'L' => match self.o { @@ -42,7 +42,7 @@ impl Robot { } /// Enum to store all possible orientations. -enum Orientation { +pub enum Orientation { N, E, S, @@ -51,9 +51,9 @@ enum Orientation { /// Struct to store robot position. #[derive(PartialEq, Eq, Hash)] -struct Position { - x: i32, - y: i32, +pub struct Position { + pub x: i32, + pub y: i32, } #[cfg(test)]