From 9e8e9253bd22b408a62a84e36b6e4a266593d722 Mon Sep 17 00:00:00 2001 From: Rico Riedel Date: Fri, 5 Aug 2022 19:38:54 +0200 Subject: [PATCH] Replace default with new --- src/main.rs | 10 +++++----- src/pattern/circle.rs | 4 ++-- src/pattern/line.rs | 4 ++-- src/pattern/rhombus.rs | 4 ++-- src/pattern/wheel.rs | 4 ++-- src/timer.rs | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0d81503..065b928 100644 --- a/src/main.rs +++ b/src/main.rs @@ -186,10 +186,10 @@ impl Args { impl PatternConfig { fn create_base(&self, rand: &mut impl Rng) -> Box { match choose(self.patterns, rand) { - PatternEnum::Circle => Box::new(CircleFactory::default()), - PatternEnum::Line => Box::new(LineFactory::default()), - PatternEnum::Rhombus => Box::new(RhombusFactory::default()), - PatternEnum::Wheel => Box::new(WheelFactory::default()), + PatternEnum::Circle => Box::new(CircleFactory::new()), + PatternEnum::Line => Box::new(LineFactory::new()), + PatternEnum::Rhombus => Box::new(RhombusFactory::new()), + PatternEnum::Wheel => Box::new(WheelFactory::new()), } } @@ -244,7 +244,7 @@ fn main() -> Result<(), Error> { let printer = PrinterImpl::new(term)?; let renderer = RendererImpl::new(sampler, converter, printer); - let clock = ClockImpl::default(); + let clock = ClockImpl::new(); let duration = Duration::from_millis(args.duration); let delay = Duration::from_nanos(1_000_000_000 / args.fps); let timer = Timer::new(clock, duration, delay); diff --git a/src/pattern/circle.rs b/src/pattern/circle.rs index 8db31aa..1bd745e 100644 --- a/src/pattern/circle.rs +++ b/src/pattern/circle.rs @@ -1,7 +1,7 @@ use crate::pattern::*; use crate::Vector; -#[derive(Default)] +#[derive(derive_more::Constructor)] pub struct CircleFactory; pub struct Circle { center: Vector, @@ -40,7 +40,7 @@ mod test { size: Vector::new(10.0, 20.0), step: 0.0, }; - let pattern = CircleFactory::default().create(&config); + let pattern = CircleFactory::new().create(&config); assert_abs_diff_eq!(1.0, pattern.sample(Vector::new(0.0, 0.0)), epsilon = 0.1); assert_abs_diff_eq!(0.0, pattern.sample(Vector::new(5.0, 10.0)), epsilon = 0.1); diff --git a/src/pattern/line.rs b/src/pattern/line.rs index c9d30d9..eb8aa5c 100644 --- a/src/pattern/line.rs +++ b/src/pattern/line.rs @@ -1,7 +1,7 @@ use crate::pattern::*; use crate::Vector; -#[derive(Default)] +#[derive(derive_more::Constructor)] pub struct LineFactory; pub struct Line { width: f32, @@ -38,7 +38,7 @@ mod test { size: Vector::new(20.0, 0.0), step: 0.0, }; - let pattern = LineFactory::default().create(&config); + let pattern = LineFactory::new().create(&config); assert_abs_diff_eq!(0.0, pattern.sample(Vector::new(0.0, 4.0)), epsilon = 0.1); assert_abs_diff_eq!(0.4, pattern.sample(Vector::new(8.0, 8.0)), epsilon = 0.1); diff --git a/src/pattern/rhombus.rs b/src/pattern/rhombus.rs index 4a79f59..480041c 100644 --- a/src/pattern/rhombus.rs +++ b/src/pattern/rhombus.rs @@ -1,7 +1,7 @@ use crate::pattern::*; use crate::Vector; -#[derive(Default)] +#[derive(derive_more::Constructor)] pub struct RhombusFactory; pub struct Rhombus { center: Vector, @@ -40,7 +40,7 @@ mod test { size: Vector::new(10.0, 5.0), step: 0.0, }; - let pattern = RhombusFactory::default().create(&config); + let pattern = RhombusFactory::new().create(&config); assert_abs_diff_eq!(1.0, pattern.sample(Vector::new(0.0, 0.0)), epsilon = 0.1); assert_abs_diff_eq!(1.0, pattern.sample(Vector::new(10.0, 5.0)), epsilon = 0.1); diff --git a/src/pattern/wheel.rs b/src/pattern/wheel.rs index c211d18..5569fe8 100644 --- a/src/pattern/wheel.rs +++ b/src/pattern/wheel.rs @@ -2,7 +2,7 @@ use crate::pattern::*; use crate::Vector; use std::f32::consts::PI; -#[derive(Default)] +#[derive(derive_more::Constructor)] pub struct WheelFactory; pub struct Wheel { center: Vector, @@ -39,7 +39,7 @@ mod test { size: Vector::new(10.0, 20.0), step: 0.0, }; - let pattern = WheelFactory::default().create(&config); + let pattern = WheelFactory::new().create(&config); assert_abs_diff_eq!(0.0, pattern.sample(Vector::new(0.0, 9.0)), epsilon = 0.1); assert_abs_diff_eq!(1.0, pattern.sample(Vector::new(0.0, 10.0)), epsilon = 0.1); diff --git a/src/timer.rs b/src/timer.rs index 67d2932..23df202 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -9,7 +9,7 @@ pub trait Clock { fn sleep(&self, duration: Duration); } -#[derive(Default)] +#[derive(derive_more::Constructor)] pub struct ClockImpl; impl Clock for ClockImpl {