From 2e4e8b3dcd1ff1a9a8565287a6525108719bb3fb Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sun, 25 Jul 2021 13:35:14 -0700 Subject: [PATCH] patterns: make From for Pattern a little generic. --- rtchallenge/src/patterns.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/rtchallenge/src/patterns.rs b/rtchallenge/src/patterns.rs index 72025f3..f586a0a 100644 --- a/rtchallenge/src/patterns.rs +++ b/rtchallenge/src/patterns.rs @@ -2,7 +2,7 @@ use crate::{ matrices::Matrix4x4, shapes::Shape, tuples::{Color, Tuple}, - Float, WHITE, + WHITE, }; #[derive(Debug, PartialEq, Clone)] @@ -34,19 +34,13 @@ impl Default for Pattern { } /// Creates a [Pattern] with a color type of [ColorMapper::Constant] from the given [Color] -impl From<[Float; 3]> for Pattern { - fn from(rgb: [Float; 3]) -> Self { +impl From for Pattern +where + C: Into, +{ + fn from(c: C) -> Self { Pattern { - color: ColorMapper::Constant(rgb.into()), - ..Pattern::default() - } - } -} -/// Creates a [Pattern] with a color type of [ColorMapper::Constant] from the given [Color] -impl From for Pattern { - fn from(c: Color) -> Self { - Pattern { - color: ColorMapper::Constant(c), + color: ColorMapper::Constant(c.into()), ..Pattern::default() } }