Cleanup, clippy

[?]
Sep 17, 2021, 8:46 AM
JPTYS433ESGA2UUNKQT4JMAWFU7KVIU7F5RKDZTUR7RR5A2COBVQC

Dependencies

  • [2] OK5CKW6E Rework everything, use references
  • [3] Y4AQJ5RD Other defaults
  • [4] C5VVJ5SO Print how many rows
  • [5] 5TH3AA46 10 mm extra space
  • [6] VSG6UWDY Can now build floors
  • [7] 6ODVKCN4 Fix printouts of relative lengths
  • [8] B75B3UUK Create a MaterialStorage
  • [9] U4JRHEA7 fmt
  • [10] ZJPL7VNQ Separate planks from main
  • [11] ES2PMPT4 Using structures instead
  • [12] CT3VONTO Introduce PLANKMIN and work with the neverending rows
  • [13] SMYRM2CF Use the MaterialStorage
  • [14] USO5PZWO Start with the print function, separate mutable and immutable functions
  • [15] LXMNVVD2 Change to proper measurements
  • [16] MLUGR2LL Add default impl and some basic plank logic
  • [17] RQRFFUF6 Can build the first basic row
  • [18] DBIA6R5X Fix get_plank()

Change contents

  • edit in src/bin/main.rs at line 20
    [2.311]
    [2.311]
    //let oldstuff = Plank {
    //length: 1000,
    //endpiece: false,
    //new: false,
    //};
    //let oldstuff2 = Plank {
    //length: 1000,
    //endpiece: false,
    //new: false,
    //};
    //ms.store_used(oldstuff);
    //ms.store_used(oldstuff2);
  • replacement in src/bin/main.rs at line 48
    [3.638][2.611:671]()
    fn floor_print(floor: &Floor, ms: &MaterialStorage) -> () {
    [3.638]
    [2.671]
    fn floor_print(floor: &Floor, ms: &MaterialStorage) {
  • replacement in src/bin/main.rs at line 86
    [3.1479][2.1274:1346]()
    fn floor_build(floor: &mut Floor, mut ms: &mut MaterialStorage) -> () {
    [3.1479]
    [3.629]
    fn floor_build(floor: &mut Floor, mut ms: &mut MaterialStorage) {
  • replacement in src/bin/main.rs at line 95
    [2.1595][2.1595:1622]()
    return ();
    [2.1595]
    [2.1622]
    return;
  • replacement in src/bin/main.rs at line 126
    [3.4041][3.658:722](),[3.722][3.4103:4236](),[3.4103][3.4103:4236]()
    if plank.length() > (ROOMLENGTH - row.get_coverage()) {
    // Cut the plank to length
    let (plankpart, leftover) = plank.cut_to_length(ROOMLENGTH - row.get_coverage());
    [3.4041]
    [3.1796]
    match plank.length() {
    length if length < (ROOMLENGTH - row.get_coverage()) => {
    // Cut the plank to length
    let (plankpart, leftover) = plank.cut_to_length(ROOMLENGTH - row.get_coverage());
  • replacement in src/bin/main.rs at line 131
    [3.1797][3.1797:1857](),[3.1857][3.103:149](),[3.149][3.4237:4287](),[3.197][3.1857:1889](),[3.4287][3.1857:1889](),[3.1857][3.1857:1889](),[3.1889][2.1805:1901](),[3.724][3.4288:4433](),[2.1901][3.4288:4433](),[3.1969][3.4288:4433]()
    // Add the remainder of plank to the row (move)
    // also increase the row coverage
    row.add_coverage(plankpart.length());
    row.add(plankpart);
    // Add the remaining plank to material storage
    ms.store_used(leftover);
    } else if plank.length() == ROOMLENGTH - row.get_coverage() {
    // If the plank is the same length as the room, no need to cut
    [3.1797]
    [3.4433]
    // Add the remainder of plank to the row (move)
    // also increase the row coverage
    row.add_coverage(plankpart.length());
    row.add(plankpart);
    // Add the remaining plank to material storage
    ms.store_used(leftover);
    }
    length if length == (ROOMLENGTH - row.get_coverage()) => {
    // If the plank is the same length as the room, no need to cut
  • replacement in src/bin/main.rs at line 141
    [3.4434][3.4434:4564]()
    // Use the whole plank, add to row coverage
    row.add_coverage(plank.length());
    row.add(plank);
    [3.4434]
    [3.4564]
    // Use the whole plank, add to row coverage
    row.add_coverage(plank.length());
    row.add(plank);
  • replacement in src/bin/main.rs at line 145
    [3.4565][3.4565:4610](),[3.4610][2.1902:1942](),[2.1942][3.335:370](),[3.4664][3.335:370](),[3.4694][3.4694:4772]()
    // Take a new plank and continue
    plank = ms.try_get_used()?;
    row.add_used_planks();
    } else {
    // Plank is shorter than the room, need multiple
    [3.4565]
    [3.4772]
    // Take a new plank and continue
    plank = ms.try_get_used()?;
    row.add_used_planks();
    }
    _ => {
    // Plank is shorter than the room, need multiple
  • replacement in src/bin/main.rs at line 152
    [3.4773][3.4773:4903]()
    // Use the whole plank, add to row coverage
    row.add_coverage(plank.length());
    row.add(plank);
    [3.4773]
    [3.4903]
    // Use the whole plank, add to row coverage
    row.add_coverage(plank.length());
    row.add(plank);
  • replacement in src/bin/main.rs at line 156
    [3.4904][3.4904:4949](),[3.4949][2.1943:1983](),[2.1983][3.371:406](),[3.5003][3.371:406]()
    // Take a new plank and continue
    plank = ms.try_get_used()?;
    row.add_used_planks();
    [3.4904]
    [3.1969]
    // Take a new plank and continue
    plank = ms.try_get_used()?;
    row.add_used_planks();
    }
  • replacement in src/constants.rs at line 12
    [2.2370][2.2370:2396]()
    pub static PLAY: u32 = 5;
    [2.2370]
    [2.2396]
    pub static PLAY: u32 = 10;
  • replacement in src/constants.rs at line 24
    [2.2632][2.2632:2670]()
    pub static AVAILABLEPLANKS: u32 = 30;
    [2.2632]
    pub static AVAILABLEPLANKS: u32 = 40;
  • replacement in src/lib.rs at line 3
    [2.2757][2.2757:2821]()
    use constants::{PLANKMAX, PLANKMIN, SAWBLADE, AVAILABLEPLANKS};
    [2.2757]
    [3.77]
    use constants::{AVAILABLEPLANKS, PLANKMAX, PLANKMIN, SAWBLADE};
  • replacement in src/lib.rs at line 15
    [3.210][3.210:249]()
    /// Create a new, default storage
    [3.210]
    [3.249]
    /// Create a new, default storage
  • replacement in src/lib.rs at line 70
    [3.148][3.148:200]()
    length: u32,
    endpiece: bool,
    new: bool,
    [3.148]
    [3.200]
    pub length: u32,
    pub endpiece: bool,
    pub new: bool,
  • replacement in src/lib.rs at line 99
    [3.737][3.737:780]()
    pub fn set_endpiece(&mut self) -> () {
    [3.737]
    [3.780]
    pub fn set_endpiece(&mut self) {
  • replacement in src/lib.rs at line 170
    [3.2133][3.2133:2172]()
    pub fn set_full(&mut self) -> () {
    [3.2133]
    [3.2172]
    pub fn set_full(&mut self) {
  • replacement in src/lib.rs at line 174
    [3.2205][2.3469:3531]()
    pub fn set_first_and_last_as_endpieces(&mut self) -> () {
    [3.2205]
    [2.3531]
    pub fn set_first_and_last_as_endpieces(&mut self) {
  • replacement in src/lib.rs at line 196
    [3.85][3.85:131]()
    pub fn add_used_planks(&mut self) -> () {
    [3.85]
    [3.131]
    pub fn add_used_planks(&mut self) {
  • replacement in src/lib.rs at line 201
    [3.2511][3.2511:2569]()
    pub fn add_coverage(&mut self, coverage: u32) -> () {
    [3.2511]
    [3.2569]
    pub fn add_coverage(&mut self, coverage: u32) {
  • replacement in src/lib.rs at line 210
    [3.2763][3.2763:2811]()
    pub fn add(&mut self, plank: Plank) -> () {
    [3.2763]
    [3.2811]
    pub fn add(&mut self, plank: Plank) {
  • replacement in src/lib.rs at line 240
    [3.245][3.245:288]()
    pub fn set_complete(&mut self) -> () {
    [3.245]
    [3.288]
    pub fn set_complete(&mut self) {
  • replacement in src/lib.rs at line 265
    [3.359][3.3423:3467](),[3.3423][3.3423:3467]()
    pub fn add(&mut self, row: Row) -> () {
    [3.359]
    [3.3467]
    pub fn add(&mut self, row: Row) {
  • replacement in src/lib.rs at line 275
    [3.535][3.535:593]()
    pub fn add_coverage(&mut self, coverage: u32) -> () {
    [3.535]
    [3.593]
    pub fn add_coverage(&mut self, coverage: u32) {