make clippy happy

This commit is contained in:
Marc Planard 2023-06-05 13:19:35 +02:00
parent a2372f9e9a
commit 1072ff4660

View File

@ -1,7 +1,7 @@
use crate::point::Point;
pub trait Transformers {
fn apply(&self, point_list: &Vec<Point>) -> Vec<Point>;
fn apply(&self, point_list: &[Point]) -> Vec<Point>;
}
/// Translate
@ -19,7 +19,7 @@ impl Translate {
}
impl Transformers for Translate {
fn apply(&self, point_list: &Vec<Point>) -> Vec<Point> {
fn apply(&self, point_list: &[Point]) -> Vec<Point> {
point_list.iter()
.map(| pt | {
Point { x: pt.x + self.x,
@ -32,6 +32,7 @@ impl Transformers for Translate {
/// Replicate
#[allow(dead_code)]
#[derive(Debug,Clone,Copy)]
pub enum Replicate {
Until(usize),
@ -39,17 +40,17 @@ pub enum Replicate {
}
impl Transformers for Replicate {
fn apply(&self, point_list: &Vec<Point>) -> Vec<Point> {
fn apply(&self, point_list: &[Point]) -> Vec<Point> {
let mut point_list2 = vec![];
match self {
Replicate::Until(n) => {
while point_list2.len() < *n {
point_list2.append(&mut point_list.clone());
point_list2.append(&mut point_list.to_vec());
}
},
Replicate::Times(n) => {
for _ in 0..*n {
point_list2.append(&mut point_list.clone());
point_list2.append(&mut point_list.to_vec());
}
}
}