Closed kornelski closed 1 month ago
I'm a bit confused by what you mean but if you mean impl From<Gray<u8>> for u8
vs impl From<Gray<u8>> for [u8; 1]
, then my question would be why not offer both?
Related to this is the question of whether we implement the pixel traits for the primitive types? Such as: impl Pixel for u8
Can't do both as generic due to overlapping implementations.
Pixel for u8
would be nice for working with grayscale, but I'm afraid it would more likely cause confusion in code that returns all image data as blobs of unsigned char.
Ah ok, yeah the overlapping implementations is really annoying. The pros of [T; 1]
are consistency with the other pixel types which might be usable in a generic context:
use rgb::Pixel;
fn test<const N: usize, P>(array: [P::Component; N])
where
P: Pixel,
P: From<[P::Component; N]>,
{
//no panic
let x = P::from(array);
//potential panic
let x = P::try_from_components(array).unwrap();
}
ok, let's keep arrays.
It seems much more useful to have From/Into that wrap/unwrap
Gray
newtype than to work with 1-channel arrays.I don't think these arrays are usable in a generic context, so consistency here may not be necessary?