Implement From instead of Into for array/tuple/mint conversions (#528)
This commit is contained in:
parent
3e93bac9f5
commit
81583b2f57
1 changed files with 9 additions and 9 deletions
|
@ -146,10 +146,10 @@ macro_rules! fold_array {
|
||||||
/// Generate array conversion implementations for a compound array type
|
/// Generate array conversion implementations for a compound array type
|
||||||
macro_rules! impl_fixed_array_conversions {
|
macro_rules! impl_fixed_array_conversions {
|
||||||
($ArrayN:ident <$S:ident> { $($field:ident : $index:expr),+ }, $n:expr) => {
|
($ArrayN:ident <$S:ident> { $($field:ident : $index:expr),+ }, $n:expr) => {
|
||||||
impl<$S> Into<[$S; $n]> for $ArrayN<$S> {
|
impl<$S> From<$ArrayN<$S>> for [$S; $n] {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> [$S; $n] {
|
fn from(v: $ArrayN<$S>) -> Self {
|
||||||
match self { $ArrayN { $($field),+ } => [$($field),+] }
|
match v { $ArrayN { $($field),+ } => [$($field),+] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,10 +194,10 @@ macro_rules! impl_fixed_array_conversions {
|
||||||
/// Generate homogeneous tuple conversion implementations for a compound array type
|
/// Generate homogeneous tuple conversion implementations for a compound array type
|
||||||
macro_rules! impl_tuple_conversions {
|
macro_rules! impl_tuple_conversions {
|
||||||
($ArrayN:ident <$S:ident> { $($field:ident),+ }, $Tuple:ty) => {
|
($ArrayN:ident <$S:ident> { $($field:ident),+ }, $Tuple:ty) => {
|
||||||
impl<$S> Into<$Tuple> for $ArrayN<$S> {
|
impl<$S> From<$ArrayN<$S>> for $Tuple {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> $Tuple {
|
fn from(v: $ArrayN<$S>) -> Self {
|
||||||
match self { $ArrayN { $($field),+ } => ($($field),+,) }
|
match v { $ArrayN { $($field),+ } => ($($field),+,) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,10 +360,10 @@ macro_rules! impl_operator_simd {
|
||||||
#[cfg(feature = "mint")]
|
#[cfg(feature = "mint")]
|
||||||
macro_rules! impl_mint_conversions {
|
macro_rules! impl_mint_conversions {
|
||||||
($ArrayN:ident { $($field:ident),+ }, $Mint:ident) => {
|
($ArrayN:ident { $($field:ident),+ }, $Mint:ident) => {
|
||||||
impl<S: Clone> Into<mint::$Mint<S>> for $ArrayN<S> {
|
impl<S: Clone> From<$ArrayN<S>> for mint::$Mint<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> mint::$Mint<S> {
|
fn from(v: $ArrayN<S>) -> Self {
|
||||||
mint::$Mint::from([$(self.$field),+])
|
mint::$Mint::from([$(v.$field),+])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue