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;