Start with the print function, separate mutable and immutable functions
[?]
Jul 11, 2020, 9:59 PM
USO5PZWOGMYH6BUHQO3AQHDQBQ4EO27OSSAVPUWCUIZVFO3PNFJQCDependencies
- [2]
C5VVJ5SOPrint how many rows - [3]
5TH3AA4610 mm extra space - [4]
MLUGR2LLAdd default impl and some basic plank logic - [5]
F3GMCMWTMerge branch 'master' into sovrum - [6]
3H2BGWRGWIP - [7]
RQRFFUF6Can build the first basic row - [8]
ZJPL7VNQSeparate planks from main - [9]
VSG6UWDYCan now build floors - [10]
2USDM5CHWIP for more generic - [11]
ES2PMPT4Using structures instead - [12]
ZJUC65PXCleanup old code
Change contents
- replacement in src/floor.rs at line 118
/// Get the number of plank rows for this floorpub fn planks(&mut self) -> &mut Vec<Plank> {/// Get a mutable reference to the plankspub fn planks_mut(&mut self) -> &mut Vec<Plank> { - edit in src/floor.rs at line 121
}/// Get a mutable reference to the plankspub fn planks(&self) -> &Vec<Plank> {&self.planks - edit in src/floor.rs at line 182
/// Get a mutable reference to the rowspub fn rows_mut(&mut self) -> &mut Vec<Row> {&mut self.rows}/// Get a mutable reference to the rowspub fn rows(&self) -> &Vec<Row> {&self.rows} - replacement in src/main.rs at line 31
let finished_floor = build_floor(floor);println!("Floor: {:#?}", finished_floor);let finished_floor = floor_build(floor);//println!("Floor: {:#?}", finished_floor);floor_print(finished_floor); - replacement in src/main.rs at line 35
println!("Number of rows: {}", finished_floor.rows_count());//println!("Number of rows: {}", finished_floor.rows_count()); - replacement in src/main.rs at line 38
fn build_floor(mut floor: Floor) -> Floor {fn floor_print(floor: Floor) -> () {for row in floor.rows().iter() {for plank in row.planks().iter() {println!("plank: {:#?}", plank);/*if planklist[x].0 == ROOMLENGTH {println!("|{:-^22}|", ROOMLENGTH);} else {// If x is oddif planklist[x].0 == planklist[x].1 {println!("|{:-^10}||{:-^10}|", planklist[x].0, planklist[x].1)} else if planklist[x].0 < planklist[x].1 {println!("|{:-^7}||{:-^13}|", planklist[x].0, planklist[x].1)} else {println!("|{:-^13}||{:-^7}|", planklist[x].0, planklist[x].1)}}*/}}println!();println!("Lycka till!");}fn floor_build(mut floor: Floor) -> Floor { - replacement in src/main.rs at line 130
if let Some(plank) = row.planks().first_mut() {if let Some(plank) = row.planks_mut().first_mut() { - replacement in src/main.rs at line 133
if let Some(plank) = row.planks().last_mut() {if let Some(plank) = row.planks_mut().last_mut() { - edit in src/main.rs at line 139[3.1229]→[3.644:645](∅→∅),[3.1583]→[3.644:645](∅→∅),[3.644]→[3.644:645](∅→∅),[3.1324]→[3.2867:3259](∅→∅),[3.3259]→[3.1442:1459](∅→∅),[3.1442]→[3.1442:1459](∅→∅),[3.1459]→[3.3260:3334](∅→∅),[3.3334]→[3.1862:1878](∅→∅),[3.1862]→[3.1862:1878](∅→∅),[3.1929]→[3.1923:1925](∅→∅),[3.1923]→[3.1923:1925](∅→∅),[3.1925]→[3.3335:3375](∅→∅)
/*for x in 0..plankcount {if planklist[x].0 == ROOMLENGTH {println!("|{:-^22}|", ROOMLENGTH);} else {// If x is oddif planklist[x].0 == planklist[x].1 {println!("|{:-^10}||{:-^10}|", planklist[x].0, planklist[x].1)} else if planklist[x].0 < planklist[x].1 {println!("|{:-^7}||{:-^13}|", planklist[x].0, planklist[x].1)} else {println!("|{:-^13}||{:-^7}|", planklist[x].0, planklist[x].1)}}}println!();println!("Lycka till!");*/