diff --git a/src/main.rs b/src/main.rs index 1b1fb42..72a535a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ #![feature(gen_blocks)] -use std::{error::Error, f32::consts::PI, sync::Arc}; +use std::{convert::identity, error::Error, f32::consts::PI, sync::Arc}; use glam::{Mat4, vec3}; use winit::{ @@ -48,7 +48,11 @@ pub fn new_tripod(device: &wgpu::Device) -> Mesh { ) } -fn loop_list( +fn loop_list(iter: impl IntoIterator) -> impl Iterator { + loop_list_ex(iter, identity, identity) +} + +fn loop_list_ex( iter: impl IntoIterator, mut fa: impl FnMut(T) -> U, mut fb: impl FnMut(T) -> U, @@ -139,19 +143,12 @@ impl MainWindow { distance: 1.0, diameter: 0.25, }; - let contour = source.contour(17); - let contour: Vec = loop_list( - contour, - |pos| Vertex { - pos, - color: vec3(1., 1., 0.), - }, - |pos| Vertex { + let contour: Vec = loop_list(source.contour(17)) + .map(|pos| Vertex { pos, color: vec3(1., 1., 1.), - }, - ) - .collect(); + }) + .collect(); self.pipeline .render(&mut pass, [&Mesh::new(&self.device, &contour)]);