Create a MaterialStorage
[?]
Mar 28, 2021, 11:20 AM
B75B3UUKURXWL6VBIJK3IKNDBH6MOLECYDOZR5LSQQILVMKFMIAACDependencies
- [2]
U4JRHEA7fmt - [3]
USO5PZWOStart with the print function, separate mutable and immutable functions - [4]
VSG6UWDYCan now build floors - [5]
5TH3AA4610 mm extra space - [6]
6ODVKCN4Fix printouts of relative lengths - [7]
ZJPL7VNQSeparate planks from main
Change contents
- edit in src/floor.rs at line 5
use crate::AVAILABLEPLANKS; - edit in src/floor.rs at line 9
pub struct MaterialStorage {total_planks: u32,planks_new: Vec<Plank>,planks_used: Vec<Plank>,planks_too_short: Vec<Plank>,}impl Default for MaterialStorage {/// Create a new, default storagefn default() -> Self {Self {total_planks: AVAILABLEPLANKS,planks_new: vec![Plank::default(); AVAILABLEPLANKS as usize],planks_used: vec![],planks_too_short: vec![],}}}impl MaterialStorage {pub fn new(&self) -> Self {MaterialStorage::default()}/// Does there exist used/cut planks?pub fn exists_used(&self) -> bool {!self.planks_used.is_empty()}/// Get a used plankpub fn get_used(&mut self) -> Option<Plank> {self.planks_used.pop()}/// Get how many cut planks existspub fn get_used_count(&self) -> u32 {self.planks_used.len() as u32}/// Does there exist new plankspub fn exists_new(&self) -> bool {!self.planks_new.is_empty()}/// Get a new plankpub fn get_new(&mut self) -> Option<Plank> {self.planks_new.pop()}}// Define a plank piece structure#[derive(Debug, Clone, Copy)] - replacement in src/floor.rs at line 234
/// Get a mutable reference to the rows/// Get a reference to the rows - edit in src/floor.rs at line 237
}/// Get a reference to the previous rowpub fn last_row(&self) -> Option<&Row> {self.rows.last() - replacement in src/main.rs at line 4
use floor::{Floor, Plank, Row};use floor::{Floor, MaterialStorage, Plank, Row};