Make Floor use Display of Row
Dependencies
- [2]
YCLKR3RZUse floor print as Display for Floor, add Row, Plank impls too - [3]
VSG6UWDYCan now build floors - [4]
ZJPL7VNQSeparate planks from main - [5]
JPTYS433Cleanup, clippy
Change contents
- replacement in src/lib.rs at line 195
for plank in &self.planks {write!(f, "{plank} ")?;let scalefactor = 50;// Try to compensate for the extra size taken by// the number printoutlet comp = 50 * self.planks_count();let mut length_sum = 0;write!(f, " ")?; // Prefix space for playfor plank in self.planks().iter() {length_sum += plank.length;write!(f, "|")?;// Print the relative length of the plankfor _ in 0..((plank.length()) / scalefactor) {write!(f, "-")?;}}write!(f, "|")?;write!(f, " Cut coordinates: ")?;for cut in self.get_cut_coordinates() {write!(f, " {cut: ^6}, ")?;}writeln!(f)?;write!(f, "+{PLAY}")?;for plank in self.planks().iter() {for _ in 0..((plank.length() - comp) / scalefactor) / 2 {write!(f, " ")?;}// Print the numeric lengthwrite!(f, "{: ^6}", plank.length())?;// Remainder of the plankfor _ in 0..((plank.length() - comp) / scalefactor) / 2 {write!(f, " ")?;}}write!(f, "+{PLAY}")?;writeln!(f, "\t Row length: {length_sum}")?;write!(f, " ")?; // Prefix space for playfor plank in self.planks().iter() {write!(f, "|")?;// Print the bottom self of the plankfor _ in 0..(plank.length() / scalefactor) {write!(f, "-")?;} - replacement in src/lib.rs at line 242
Ok(())writeln!(f, "|") - edit in src/lib.rs at line 374
}}}impl Display for Floor {fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {for (num, row) in self.rows().iter().enumerate() {writeln!(f, "Row: {:#?}", num + 1)?;writeln!(f, "{row}")?; - edit in src/lib.rs at line 384
Ok(()) - edit in src/lib.rs at line 434[2.358]→[2.358:2320](∅→∅),[3.628]→[3.3496:3504](∅→∅),[2.2320]→[3.3496:3504](∅→∅),[3.3496]→[3.3496:3504](∅→∅)
impl Display for Floor {fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {let scalefactor = 50;for (num, row) in self.rows().iter().enumerate() {// Try to compensate for the extra size taken by// the number printoutlet comp = 50 * row.planks_count();let mut length_sum = 0;write!(f, " ")?; // Prefix space for playfor plank in row.planks().iter() {length_sum += plank.length;write!(f, "|")?;// Print the relative length of the plankfor _ in 0..((plank.length()) / scalefactor) {write!(f, "-")?;}}write!(f, "|")?;write!(f, " Cut coordinates: ")?;for cut in row.get_cut_coordinates() {write!(f, " {cut: ^6}, ")?;}writeln!(f)?;write!(f, "+{PLAY}")?;for plank in row.planks().iter() {for _ in 0..((plank.length() - comp) / scalefactor) / 2 {write!(f, " ")?;}// Print the numeric lengthwrite!(f, "{: ^6}", plank.length())?;// Remainder of the plankfor _ in 0..((plank.length() - comp) / scalefactor) / 2 {write!(f, " ")?;}}write!(f, "+{PLAY}")?;writeln!(f, "\t Row length: {length_sum}\trow: {:#?}", num + 1)?;write!(f, " ")?; // Prefix space for playfor plank in row.planks().iter() {write!(f, "|")?;// Print the bottom row of the plankfor _ in 0..(plank.length() / scalefactor) {write!(f, "-")?;}}writeln!(f, "|")?;writeln!(f)?;}Ok(())}}