diff options
Diffstat (limited to 'src/structs.rs')
-rw-r--r-- | src/structs.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/structs.rs b/src/structs.rs index c61bb14..67cce30 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -3,16 +3,19 @@ pub struct StoneWall { rows: Vec<Vec<u32>>, } +#[allow(clippy::option_map_unit_fn)] impl StoneWall { + #[allow(dead_code)] pub fn create_empty(n: u32) -> Self { let n = n as usize; let h = n / 2 + 1; let mut rows = vec![vec![0; n]; h]; - rows.get_mut(0).map(|r| r[0] = 1); - rows.get_mut(1).map(|r| r[1] = 2); + rows.get_mut(0).map(|r| r[0] = 1); // Should be rewitten to express + rows.get_mut(1).map(|r| r[1] = 2); // its purpose more clearly Self { rows } } + #[allow(dead_code)] pub fn set_stone(&mut self, row: u32, pos: u32, stone: u32) -> Option<()> { self.rows .get_mut(row as usize) @@ -20,6 +23,7 @@ impl StoneWall { .map(|v| *v = stone) } + #[allow(dead_code)] pub fn output(&mut self) { let colors = [[31, 32], [33, 35]]; //self.rows.sort_by_key(|x| x[0]); @@ -43,6 +47,7 @@ pub struct GapHeights { } impl GapHeights { + #[allow(dead_code)] pub fn from_heights(heights: Vec<u32>) -> Self { Self { heights } } @@ -62,10 +67,12 @@ impl GapHeights { Self { heights } } + #[allow(dead_code)] pub fn add_gap(&mut self, height: u32) { self.heights.push(height) } + #[allow(dead_code)] pub fn calculate_row(&self, r: u32, stones: &mut [u32]) { let mut len = 1; let mut i = 0; @@ -79,9 +86,9 @@ impl GapHeights { } } + #[allow(dead_code)] pub fn output(&self, n: u32, h: u32) { let mut stones = vec![0; n as usize]; - let mut toggle = 0; let mut colors = [ "\x1b[31m", "\x1b[32m", "\x1b[33m", "\x1b[34m", "\x1b[35m", "\x1b[36m", ] @@ -107,13 +114,15 @@ impl GapHeights { } } - pub fn iter<'a>(&'a self) -> GapIter<'a> { + #[allow(dead_code)] + pub fn iter(&self) -> GapIter { GapIter { gap_heights: self, i: 0, } } + #[allow(dead_code)] pub fn as_stone_wall(&self, n: u32) -> StoneWall { let h = n / 2 + 1; let mut rows = Vec::with_capacity(h as usize); @@ -136,6 +145,6 @@ impl<'a> Iterator for GapIter<'a> { fn next(&mut self) -> Option<Self::Item> { let i = self.i; self.i += 1; - self.gap_heights.heights.get(i).map(|&x| x) + self.gap_heights.heights.get(i).cloned() } } |