From 0f86c727cb984dce35424ee398755bde6e78bf3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20M=C3=BCller?= Date: Sat, 10 Jun 2023 21:07:29 +0200 Subject: [PATCH] combined the trait bounds to the trait "Sample" --- src/image/mod.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/image/mod.rs b/src/image/mod.rs index 1fec483..e38ce21 100644 --- a/src/image/mod.rs +++ b/src/image/mod.rs @@ -35,11 +35,15 @@ use std::path::PathBuf; use std::slice::{Iter, IterMut}; use std::vec::IntoIter; +pub trait Sample: Into + PartialEq + Default + Copy + From + PartialOrd {} + +impl + PartialEq + Default + Copy + From + PartialOrd> Sample for T {} + #[allow(unused)] #[derive(Default)] pub struct Image where - T: Into + PartialEq + Default + Copy + From + PartialOrd, + T: Sample, { ///the width of the Picture in px width: u32, @@ -54,7 +58,7 @@ where #[allow(unused)] impl Image where - T: Into + PartialEq + Default + Copy + From + PartialOrd, + T: Sample, { ///gives an Image with specified values if the Vec matches the width times the height of the Image /// if the width and height dont make sense for the Image then will this function panic. @@ -125,7 +129,7 @@ where impl Index for Image where - T: Into + PartialEq + Default + Copy + From + PartialOrd, + T: Sample, { type Output = (T, T, T, T); fn index(&self, index: usize) -> &Self::Output { @@ -135,7 +139,7 @@ where impl IndexMut for Image where - T: Into + PartialEq + Default + Copy + From + PartialOrd, + T: Sample, { fn index_mut(&mut self, index: usize) -> &mut Self::Output { &mut self.pixels[index] @@ -144,7 +148,7 @@ where impl IntoIterator for Image where - T: Into + PartialEq + Default + Copy + From + PartialOrd, + T: Sample, { type Item = (T, T, T, T); type IntoIter = IntoIter;