From cf66eccb753f3cf28928de7536cd9c51b48166ab Mon Sep 17 00:00:00 2001 From: Olexorus Date: Tue, 15 Mar 2022 16:34:56 +0100 Subject: [PATCH] Use Rust 2021 postfix .into_iter() --- common/systems/src/phys.rs | 6 +++--- world/src/sim/mod.rs | 27 +++++++++++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/common/systems/src/phys.rs b/common/systems/src/phys.rs index e45fe28a60..4ad86edfed 100644 --- a/common/systems/src/phys.rs +++ b/common/systems/src/phys.rs @@ -1972,13 +1972,13 @@ fn closest_points(n: LineSegment2, m: LineSegment2) -> (Vec2, Vec // Check to see whether the lines are parallel if !t.is_finite() || !u.is_finite() { - // TODO: can use postfix .into_iter() when switching to Rust 2021 - IntoIterator::into_iter([ + [ (n.projected_point(m.start), m.start), (n.projected_point(m.end), m.end), (n.start, m.projected_point(n.start)), (n.end, m.projected_point(n.end)), - ]) + ] + .into_iter() .min_by_key(|(a, b)| ordered_float::OrderedFloat(a.distance_squared(*b))) .expect("Lines had non-finite elements") } else { diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index e050f0d048..bf9d7becb6 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -2130,18 +2130,21 @@ impl WorldSim { /// them spawning). pub fn get_near_trees(&self, wpos: Vec2) -> impl Iterator + '_ { // Deterministic based on wpos - // TODO: can use postfix .into_iter() when switching to Rust 2021 - let normal_trees = IntoIterator::into_iter(self.gen_ctx.structure_gen.get(wpos)) - .filter_map(move |(wpos, seed)| { - let lottery = self.make_forest_lottery(wpos); - Some(TreeAttr { - pos: wpos, - seed, - scale: 1.0, - forest_kind: *lottery.choose_seeded(seed).as_ref()?, - inhabited: false, - }) - }); + let normal_trees = + self.gen_ctx + .structure_gen + .get(wpos) + .into_iter() + .filter_map(move |(wpos, seed)| { + let lottery = self.make_forest_lottery(wpos); + Some(TreeAttr { + pos: wpos, + seed, + scale: 1.0, + forest_kind: *lottery.choose_seeded(seed).as_ref()?, + inhabited: false, + }) + }); // // For testing // let giant_trees =