combined the trait bounds to the trait "Sample"
This commit is contained in:
parent
bbbb85d5ba
commit
0f86c727cb
|
@ -35,11 +35,15 @@ use std::path::PathBuf;
|
|||
use std::slice::{Iter, IterMut};
|
||||
use std::vec::IntoIter;
|
||||
|
||||
pub trait Sample: Into<f32> + PartialEq + Default + Copy + From<u8> + PartialOrd {}
|
||||
|
||||
impl<T: Into<f32> + PartialEq + Default + Copy + From<u8> + PartialOrd> Sample for T {}
|
||||
|
||||
#[allow(unused)]
|
||||
#[derive(Default)]
|
||||
pub struct Image<T>
|
||||
where
|
||||
T: Into<f32> + PartialEq + Default + Copy + From<u8> + PartialOrd,
|
||||
T: Sample,
|
||||
{
|
||||
///the width of the Picture in px
|
||||
width: u32,
|
||||
|
@ -54,7 +58,7 @@ where
|
|||
#[allow(unused)]
|
||||
impl<T> Image<T>
|
||||
where
|
||||
T: Into<f32> + PartialEq + Default + Copy + From<u8> + 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<T> Index<usize> for Image<T>
|
||||
where
|
||||
T: Into<f32> + PartialEq + Default + Copy + From<u8> + PartialOrd,
|
||||
T: Sample,
|
||||
{
|
||||
type Output = (T, T, T, T);
|
||||
fn index(&self, index: usize) -> &Self::Output {
|
||||
|
@ -135,7 +139,7 @@ where
|
|||
|
||||
impl<T> IndexMut<usize> for Image<T>
|
||||
where
|
||||
T: Into<f32> + PartialEq + Default + Copy + From<u8> + PartialOrd,
|
||||
T: Sample,
|
||||
{
|
||||
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
|
||||
&mut self.pixels[index]
|
||||
|
@ -144,7 +148,7 @@ where
|
|||
|
||||
impl<T> IntoIterator for Image<T>
|
||||
where
|
||||
T: Into<f32> + PartialEq + Default + Copy + From<u8> + PartialOrd,
|
||||
T: Sample,
|
||||
{
|
||||
type Item = (T, T, T, T);
|
||||
type IntoIter = IntoIter<Self::Item>;
|
||||
|
|
Loading…
Reference in New Issue