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