diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-08-19 10:30:13 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-08-19 10:30:13 +0200 |
commit | c289fe4e48cbb4d9b9cdf925993b783c44deaf9b (patch) | |
tree | 306061f7e2e75404ee7c83c37522839eed3bd6b5 | |
parent | fba7a99bb5e5b6b21af428afeccfbcf248b58f49 (diff) |
Fix: Special case with two elements in the simulation was not covered
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | src/backend.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend.rs b/src/backend.rs index 79da303..07bbea1 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -46,7 +46,8 @@ impl Landscape { .map(ElementRainingSimulation::new) .collect::<Vec<_>>(); - { + if simulation_elements.len() >= 3 { + log::debug!("Having three or more landscape elements in the simulation, pairing them now"); let mut windows = ThreeElemWindowMut::new(&mut simulation_elements); while let Some(mut window) = windows.next() { // we know from the ThreeElemWindowMut impl that 'window' always has three elements @@ -57,6 +58,10 @@ impl Landscape { window[1].right_neighbor = Some(window[2].element.clone()); window[2].left_neighbor = Some(window[1].element.clone()); } + } else if simulation_elements.len() == 2 { + log::debug!("Having only two landscape elements in the simulation, pairing them now"); + simulation_elements[0].right_neighbor = Some(simulation_elements[1].element.clone()); + simulation_elements[1].left_neighbor = Some(simulation_elements[0].element.clone()); } Ok(simulation_elements) |