Fix building with SIMD enabled

This commit is contained in:
Osspial 2017-08-16 16:47:45 -04:00
parent a6abd5bf02
commit bd1b2667bd

View file

@ -347,8 +347,14 @@ macro_rules! impl_vector_default {
impl<S: NumCast + Copy> $VectorN<S> { impl<S: NumCast + Copy> $VectorN<S> {
/// Component-wise casting to another type. /// Component-wise casting to another type.
#[inline] #[inline]
pub fn cast<T: NumCast>(&self) -> $VectorN<T> { pub fn cast<T: NumCast>(&self) -> Option<$VectorN<T>> {
$VectorN { $($field: NumCast::from(self.$field).unwrap()),+ } $(
let $field = match NumCast::from(self.$field) {
Some(field) => field,
None => return None
};
)+
Some($VectorN { $($field),+ })
} }
} }