Use the MaterialStorage

[?]
Mar 28, 2021, 11:21 AM
SMYRM2CFBM7BJYHAUIJYTSORS2V6O5GAHRSY2K6ELGOM3OF5VHCQC

Dependencies

  • [2] 6ODVKCN4 Fix printouts of relative lengths
  • [3] 3H2BGWRG WIP
  • [4] 5TH3AA46 10 mm extra space
  • [5] UPCMFGXF Print more about the room and define PLAY
  • [6] RQRFFUF6 Can build the first basic row
  • [7] F3GMCMWT Merge branch 'master' into sovrum
  • [8] CT3VONTO Introduce PLANKMIN and work with the neverending rows
  • [9] 2USDM5CH WIP for more generic
  • [10] VSG6UWDY Can now build floors
  • [11] Y4AQJ5RD Other defaults
  • [12] ES2PMPT4 Using structures instead
  • [13] ZJPL7VNQ Separate planks from main
  • [14] USO5PZWO Start with the print function, separate mutable and immutable functions
  • [15] JBGHRTSW Use the new defaults
  • [16] MLUGR2LL Add default impl and some basic plank logic
  • [*] C5VVJ5SO Print how many rows

Change contents

  • replacement in src/main.rs at line 20
    [3.347][3.347:378](),[3.378][2.22:51]()
    //static PLANKMAX: u32 = 2200;
    static PLANKMAX: u32 = 1900;
    [3.347]
    [3.509]
    static PLANKMAX: u32 = 2200;
    //static PLANKMAX: u32 = 1900;
  • replacement in src/main.rs at line 25
    [3.437][3.59:82](),[3.59][3.59:82]()
    static PLAY: u32 = 20;
    [3.437]
    [3.3670]
    static PLAY: u32 = 5;
  • edit in src/main.rs at line 31
    [18.231]
    [3.143]
    // How many planks are available?
    // Add ability to add "used"/pre-cut planks
    static AVAILABLEPLANKS: u32 = 10;
  • replacement in src/main.rs at line 39
    [3.145][3.145:186]()
    println!("Halloj golvläggare!)\n");
    [3.145]
    [3.99]
    println!("Halloj golvläggare!\n");
  • edit in src/main.rs at line 46
    [2.264]
    [3.186]
    // Create a pool of planks, modify the constant AVAILABLEPLANKS
    // to the total number of full length available planks
    let ms = MaterialStorage::default();
  • replacement in src/main.rs at line 51
    [3.237][3.237:280]()
    let floor: Floor = Default::default();
    [3.187]
    [3.296]
    let floor: Floor = Floor::default();
    //println!("Material storage:\n {:#?}", ms);
  • replacement in src/main.rs at line 55
    [3.297][3.451:496]()
    let finished_floor = floor_build(floor);
    [3.297]
    [3.496]
    let (finished_floor, ms) = floor_build(floor, ms);
  • edit in src/main.rs at line 58
    [3.573]
    [3.1250]
    println!("Number of leftover cut planks: {}", ms.get_used_count());
  • replacement in src/main.rs at line 92
    [3.1144][3.1144:1204]()
    println!("Number of planks used: {}", plank_count_sum);
    [3.1144]
    [3.1476]
    println!("Number of planks required: {}", plank_count_sum);
  • replacement in src/main.rs at line 95
    [3.1479][3.1479:1523]()
    fn floor_build(mut floor: Floor) -> Floor {
    [3.1479]
    [3.629]
    fn floor_build(mut floor: Floor, mut ms: MaterialStorage) -> (Floor, MaterialStorage) {
  • replacement in src/main.rs at line 98
    [3.674][3.1317:1349](),[2.823][3.1317:1349](),[3.1264][3.1317:1349](),[3.1317][3.1317:1349]()
    floor.add(build_row());
    [2.823]
    [3.675]
    // TODO, deal with unwrap
    floor.add(build_row(&mut ms).unwrap());
  • replacement in src/main.rs at line 104
    [3.102][3.1326:1336](),[3.450][3.1326:1336]()
    floor
    [3.450]
    [3.1336]
    (floor, ms)
  • replacement in src/main.rs at line 107
    [3.557][3.1339:1363]()
    fn build_row() -> Row {
    [3.557]
    [3.1356]
    fn build_row(ms: &mut MaterialStorage) -> Option<Row> {
  • replacement in src/main.rs at line 112
    [3.1452][3.1452:1499]()
    let mut plank: Plank = Default::default();
    [3.1452]
    [3.1551]
    //let mut plank: Plank = Default::default();
    // Check if some started plank is available
    // otherwise grab a new plank from MaterialStorage
    let mut plank;
    if ms.exists_used() {
    plank = ms.get_used()?;
    } else {
    plank = ms.get_new()?;
    //} else {
    //println!("No more planks available!");
    //plank = None;
    //}
    }
  • replacement in src/main.rs at line 182
    [3.5359][3.1980:1988](),[3.1424][3.1980:1988]()
    row
    [3.5359]
    [3.1424]
    Some(row)