Skip to content

Commit

Permalink
make from conversion less generic (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
ripytide authored and kornelski committed Jul 7, 2024
1 parent b289276 commit efc0cdc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ use crate::{Abgr, Argb, Bgr, Bgra, Gray, GrayA, Grb, Rgb, Rgba};

macro_rules! without_alpha {
($from_type:ident, $self_type:ident, {$($bit:tt),*}) => {
impl<R, S> From<$from_type<R>> for $self_type<S> where R: Into<S> {
fn from(value: $from_type<R>) -> Self {
impl<T> From<$from_type<T>> for $self_type<T> {
fn from(value: $from_type<T>) -> Self {
Self{$($bit: value.$bit.into()),*}
}
}
};
}
macro_rules! with_alpha {
($from_type:ident, $self_type:ident, {$($bit:tt),*}) => {
impl<R, S, T, U> From<$from_type<R, S>> for $self_type<T, U> where R: Into<T>, S: Into<U> {
fn from(value: $from_type<R, S>) -> Self {
impl<T, A> From<$from_type<T, A>> for $self_type<T, A> {
fn from(value: $from_type<T, A>) -> Self {
Self{$($bit: value.$bit.into()),*}
}
}
};
}
macro_rules! alpha_to_no_alpha {
($from_type:ident, $self_type:ident, {$($bit:tt),*}) => {
impl<R, S, T> From<$from_type<R, S>> for $self_type<T> where R: Into<T> {
fn from(value: $from_type<R, S>) -> Self {
impl<T, A> From<$from_type<T, A>> for $self_type<T> {
fn from(value: $from_type<T, A>) -> Self {
Self{$($bit: value.$bit.into()),*}
}
}
Expand Down

0 comments on commit efc0cdc

Please sign in to comment.