# HG changeset patch # User alfadur # Date 1541115061 -10800 # Node ID 3f21f27c65645ba49d54bdd2e84a06423ec1fe9f # Parent 649ccb9f8cfde60552b04c29534adbf98f0a64a9 wrestle with borrow checker diff -r 649ccb9f8cfd -r 3f21f27c6564 rust/landgen/src/template_based.rs --- a/rust/landgen/src/template_based.rs Fri Nov 02 00:09:05 2018 +0100 +++ b/rust/landgen/src/template_based.rs Fri Nov 02 02:31:01 2018 +0300 @@ -57,19 +57,27 @@ fn divide_edges>(&mut self, random_numbers: &mut I) { for is in 0..self.islands.len() { - let island = &mut self.islands[is]; let mut i = 0; + let mut start_point = Point::zero(); + let mut end_point = Point::zero(); - while i < island.len() { - let start_point = island[i]; - let end_point = if i + 1 < island.len() { - island[i + 1] - } else { - island[0] - }; + loop { + { + let island = &self.islands[is]; + if i < island.len() { + start_point = island[i]; + end_point = if i + 1 < island.len() { + island[i + 1] + } else { + island[0] + }; + } else { + break + } + } if let Some(new_point) = self.divide_edge(start_point, end_point, random_numbers) { - (*island).insert(i + 1, new_point); + self.islands[is].insert(i + 1, new_point); i += 2; } else { i += 1;