mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use Rust 2021 postfix .into_iter()
This commit is contained in:
parent
998b1deb15
commit
cf66eccb75
@ -1972,13 +1972,13 @@ fn closest_points(n: LineSegment2<f32>, m: LineSegment2<f32>) -> (Vec2<f32>, Vec
|
|||||||
|
|
||||||
// Check to see whether the lines are parallel
|
// Check to see whether the lines are parallel
|
||||||
if !t.is_finite() || !u.is_finite() {
|
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.start), m.start),
|
||||||
(n.projected_point(m.end), m.end),
|
(n.projected_point(m.end), m.end),
|
||||||
(n.start, m.projected_point(n.start)),
|
(n.start, m.projected_point(n.start)),
|
||||||
(n.end, m.projected_point(n.end)),
|
(n.end, m.projected_point(n.end)),
|
||||||
])
|
]
|
||||||
|
.into_iter()
|
||||||
.min_by_key(|(a, b)| ordered_float::OrderedFloat(a.distance_squared(*b)))
|
.min_by_key(|(a, b)| ordered_float::OrderedFloat(a.distance_squared(*b)))
|
||||||
.expect("Lines had non-finite elements")
|
.expect("Lines had non-finite elements")
|
||||||
} else {
|
} else {
|
||||||
|
@ -2130,18 +2130,21 @@ impl WorldSim {
|
|||||||
/// them spawning).
|
/// them spawning).
|
||||||
pub fn get_near_trees(&self, wpos: Vec2<i32>) -> impl Iterator<Item = TreeAttr> + '_ {
|
pub fn get_near_trees(&self, wpos: Vec2<i32>) -> impl Iterator<Item = TreeAttr> + '_ {
|
||||||
// Deterministic based on wpos
|
// Deterministic based on wpos
|
||||||
// TODO: can use postfix .into_iter() when switching to Rust 2021
|
let normal_trees =
|
||||||
let normal_trees = IntoIterator::into_iter(self.gen_ctx.structure_gen.get(wpos))
|
self.gen_ctx
|
||||||
.filter_map(move |(wpos, seed)| {
|
.structure_gen
|
||||||
let lottery = self.make_forest_lottery(wpos);
|
.get(wpos)
|
||||||
Some(TreeAttr {
|
.into_iter()
|
||||||
pos: wpos,
|
.filter_map(move |(wpos, seed)| {
|
||||||
seed,
|
let lottery = self.make_forest_lottery(wpos);
|
||||||
scale: 1.0,
|
Some(TreeAttr {
|
||||||
forest_kind: *lottery.choose_seeded(seed).as_ref()?,
|
pos: wpos,
|
||||||
inhabited: false,
|
seed,
|
||||||
})
|
scale: 1.0,
|
||||||
});
|
forest_kind: *lottery.choose_seeded(seed).as_ref()?,
|
||||||
|
inhabited: false,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
// // For testing
|
// // For testing
|
||||||
// let giant_trees =
|
// let giant_trees =
|
||||||
|
Loading…
Reference in New Issue
Block a user