Add Scalar + Copy bounds to code that's under feature flags.

`./ci/test.sh` now passes locally.

Refactoring done via the following sed commands:
```bash
export RELEVANT_SOURCEFILES="$(find src -name '*.rs') $(find examples -name '*.rs')"
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Arbitrary\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Serialize\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Deserialize\)/N\1: Scalar + Copy + \2/' $f; do
export RELEVANT_SOURCEFILES="$(find nalgebra-glm -name '*.rs')"
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar,/N\1: Scalar + Copy,/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar>/N\1: Scalar + Copy>/' $f; done
for f in algebra-glm/src/traits.rs; do sed -i 's/Scalar + Ring/Scalar + Copy + Ring>/' $f; done # Number trait definition
```
This commit is contained in:
Avi Weinstock 2019-11-21 16:43:58 -05:00
parent 4d38537240
commit fb573f726c
17 changed files with 106 additions and 106 deletions

View File

@ -297,13 +297,13 @@ where DefaultAllocator: Alloc<f32, D> {
v.map(int_bits_to_float)
}
//pub fn isinf<N: Scalar, D: Dimension>(x: &TVec<N, D>) -> TVec<bool, D>
//pub fn isinf<N: Scalar + Copy, D: Dimension>(x: &TVec<N, D>) -> TVec<bool, D>
// where DefaultAllocator: Alloc<N, D> {
// unimplemented!()
//
//}
//
//pub fn isnan<N: Scalar, D: Dimension>(x: &TVec<N, D>) -> TVec<bool, D>
//pub fn isnan<N: Scalar + Copy, D: Dimension>(x: &TVec<N, D>) -> TVec<bool, D>
// where DefaultAllocator: Alloc<N, D> {
// unimplemented!()
//
@ -504,7 +504,7 @@ where DefaultAllocator: Alloc<N, D> {
x.map(|x| x.round())
}
//pub fn roundEven<N: Scalar, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
//pub fn roundEven<N: Scalar + Copy, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
// where DefaultAllocator: Alloc<N, D> {
// unimplemented!()
//}

View File

@ -15,28 +15,28 @@ use crate::aliases::{TMat, Qua, TVec1, TVec2, TVec3, TVec4, TMat2, TMat2x3, TMat
/// # use nalgebra_glm as glm;
/// let v = glm::vec1(true);
/// ```
pub fn vec1<N: Scalar>(x: N) -> TVec1<N> {
pub fn vec1<N: Scalar + Copy>(x: N) -> TVec1<N> {
TVec1::new(x)
}
/// Creates a new 2D vector.
pub fn vec2<N: Scalar>(x: N, y: N) -> TVec2<N> {
pub fn vec2<N: Scalar + Copy>(x: N, y: N) -> TVec2<N> {
TVec2::new(x, y)
}
/// Creates a new 3D vector.
pub fn vec3<N: Scalar>(x: N, y: N, z: N) -> TVec3<N> {
pub fn vec3<N: Scalar + Copy>(x: N, y: N, z: N) -> TVec3<N> {
TVec3::new(x, y, z)
}
/// Creates a new 4D vector.
pub fn vec4<N: Scalar>(x: N, y: N, z: N, w: N) -> TVec4<N> {
pub fn vec4<N: Scalar + Copy>(x: N, y: N, z: N, w: N) -> TVec4<N> {
TVec4::new(x, y, z, w)
}
/// Create a new 2x2 matrix.
pub fn mat2<N: Scalar>(m11: N, m12: N,
pub fn mat2<N: Scalar + Copy>(m11: N, m12: N,
m21: N, m22: N) -> TMat2<N> {
TMat::<N, U2, U2>::new(
m11, m12,
@ -45,7 +45,7 @@ pub fn mat2<N: Scalar>(m11: N, m12: N,
}
/// Create a new 2x2 matrix.
pub fn mat2x2<N: Scalar>(m11: N, m12: N,
pub fn mat2x2<N: Scalar + Copy>(m11: N, m12: N,
m21: N, m22: N) -> TMat2<N> {
TMat::<N, U2, U2>::new(
m11, m12,
@ -54,7 +54,7 @@ pub fn mat2x2<N: Scalar>(m11: N, m12: N,
}
/// Create a new 2x3 matrix.
pub fn mat2x3<N: Scalar>(m11: N, m12: N, m13: N,
pub fn mat2x3<N: Scalar + Copy>(m11: N, m12: N, m13: N,
m21: N, m22: N, m23: N) -> TMat2x3<N> {
TMat::<N, U2, U3>::new(
m11, m12, m13,
@ -63,7 +63,7 @@ pub fn mat2x3<N: Scalar>(m11: N, m12: N, m13: N,
}
/// Create a new 2x4 matrix.
pub fn mat2x4<N: Scalar>(m11: N, m12: N, m13: N, m14: N,
pub fn mat2x4<N: Scalar + Copy>(m11: N, m12: N, m13: N, m14: N,
m21: N, m22: N, m23: N, m24: N) -> TMat2x4<N> {
TMat::<N, U2, U4>::new(
m11, m12, m13, m14,
@ -72,7 +72,7 @@ pub fn mat2x4<N: Scalar>(m11: N, m12: N, m13: N, m14: N,
}
/// Create a new 3x3 matrix.
pub fn mat3<N: Scalar>(m11: N, m12: N, m13: N,
pub fn mat3<N: Scalar + Copy>(m11: N, m12: N, m13: N,
m21: N, m22: N, m23: N,
m31: N, m32: N, m33: N) -> TMat3<N> {
TMat::<N, U3, U3>::new(
@ -83,7 +83,7 @@ pub fn mat3<N: Scalar>(m11: N, m12: N, m13: N,
}
/// Create a new 3x2 matrix.
pub fn mat3x2<N: Scalar>(m11: N, m12: N,
pub fn mat3x2<N: Scalar + Copy>(m11: N, m12: N,
m21: N, m22: N,
m31: N, m32: N) -> TMat3x2<N> {
TMat::<N, U3, U2>::new(
@ -94,7 +94,7 @@ pub fn mat3x2<N: Scalar>(m11: N, m12: N,
}
/// Create a new 3x3 matrix.
pub fn mat3x3<N: Scalar>(m11: N, m12: N, m13: N,
pub fn mat3x3<N: Scalar + Copy>(m11: N, m12: N, m13: N,
m21: N, m22: N, m23: N,
m31: N, m32: N, m33: N) -> TMat3<N> {
TMat::<N, U3, U3>::new(
@ -105,7 +105,7 @@ pub fn mat3x3<N: Scalar>(m11: N, m12: N, m13: N,
}
/// Create a new 3x4 matrix.
pub fn mat3x4<N: Scalar>(m11: N, m12: N, m13: N, m14: N,
pub fn mat3x4<N: Scalar + Copy>(m11: N, m12: N, m13: N, m14: N,
m21: N, m22: N, m23: N, m24: N,
m31: N, m32: N, m33: N, m34: N) -> TMat3x4<N> {
TMat::<N, U3, U4>::new(
@ -116,7 +116,7 @@ pub fn mat3x4<N: Scalar>(m11: N, m12: N, m13: N, m14: N,
}
/// Create a new 4x2 matrix.
pub fn mat4x2<N: Scalar>(m11: N, m12: N,
pub fn mat4x2<N: Scalar + Copy>(m11: N, m12: N,
m21: N, m22: N,
m31: N, m32: N,
m41: N, m42: N) -> TMat4x2<N> {
@ -129,7 +129,7 @@ pub fn mat4x2<N: Scalar>(m11: N, m12: N,
}
/// Create a new 4x3 matrix.
pub fn mat4x3<N: Scalar>(m11: N, m12: N, m13: N,
pub fn mat4x3<N: Scalar + Copy>(m11: N, m12: N, m13: N,
m21: N, m22: N, m23: N,
m31: N, m32: N, m33: N,
m41: N, m42: N, m43: N) -> TMat4x3<N> {
@ -142,7 +142,7 @@ pub fn mat4x3<N: Scalar>(m11: N, m12: N, m13: N,
}
/// Create a new 4x4 matrix.
pub fn mat4x4<N: Scalar>(m11: N, m12: N, m13: N, m14: N,
pub fn mat4x4<N: Scalar + Copy>(m11: N, m12: N, m13: N, m14: N,
m21: N, m22: N, m23: N, m24: N,
m31: N, m32: N, m33: N, m34: N,
m41: N, m42: N, m43: N, m44: N) -> TMat4<N> {
@ -155,7 +155,7 @@ pub fn mat4x4<N: Scalar>(m11: N, m12: N, m13: N, m14: N,
}
/// Create a new 4x4 matrix.
pub fn mat4<N: Scalar>(m11: N, m12: N, m13: N, m14: N,
pub fn mat4<N: Scalar + Copy>(m11: N, m12: N, m13: N, m14: N,
m21: N, m22: N, m23: N, m24: N,
m31: N, m32: N, m33: N, m34: N,
m41: N, m42: N, m43: N, m44: N) -> TMat4<N> {

View File

@ -19,7 +19,7 @@ pub fn bitfieldFillOne<IU>(Value: IU, FirstBit: i32, BitCount: i32) -> IU {
unimplemented!()
}
pub fn bitfieldFillOne2<N: Scalar, D: Dimension>(Value: &TVec<N, D>, FirstBit: i32, BitCount: i32) -> TVec<N, D>
pub fn bitfieldFillOne2<N: Scalar + Copy, D: Dimension>(Value: &TVec<N, D>, FirstBit: i32, BitCount: i32) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -28,7 +28,7 @@ pub fn bitfieldFillZero<IU>(Value: IU, FirstBit: i32, BitCount: i32) -> IU {
unimplemented!()
}
pub fn bitfieldFillZero2<N: Scalar, D: Dimension>(Value: &TVec<N, D>, FirstBit: i32, BitCount: i32) -> TVec<N, D>
pub fn bitfieldFillZero2<N: Scalar + Copy, D: Dimension>(Value: &TVec<N, D>, FirstBit: i32, BitCount: i32) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -113,7 +113,7 @@ pub fn bitfieldRotateLeft<IU>(In: IU, Shift: i32) -> IU {
unimplemented!()
}
pub fn bitfieldRotateLeft2<N: Scalar, D: Dimension>(In: &TVec<N, D>, Shift: i32) -> TVec<N, D>
pub fn bitfieldRotateLeft2<N: Scalar + Copy, D: Dimension>(In: &TVec<N, D>, Shift: i32) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -122,7 +122,7 @@ pub fn bitfieldRotateRight<IU>(In: IU, Shift: i32) -> IU {
unimplemented!()
}
pub fn bitfieldRotateRight2<N: Scalar, D: Dimension>(In: &TVec<N, D>, Shift: i32) -> TVec<N, D>
pub fn bitfieldRotateRight2<N: Scalar + Copy, D: Dimension>(In: &TVec<N, D>, Shift: i32) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -131,7 +131,7 @@ pub fn mask<IU>(Bits: IU) -> IU {
unimplemented!()
}
pub fn mask2<N: Scalar, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
pub fn mask2<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}

View File

@ -3,7 +3,7 @@
//use crate::traits::{Alloc, Dimension};
//use crate::aliases::TVec;
//pub fn iround<N: Scalar, D: Dimension>(x: &TVec<N, D>) -> TVec<i32, D>
//pub fn iround<N: Scalar + Copy, D: Dimension>(x: &TVec<N, D>) -> TVec<i32, D>
// where DefaultAllocator: Alloc<N, D> {
// x.map(|x| x.round())
//}
@ -12,7 +12,7 @@
// unimplemented!()
//}
//
//pub fn uround<N: Scalar, D: Dimension>(x: &TVec<N, D>) -> TVec<u32, D>
//pub fn uround<N: Scalar + Copy, D: Dimension>(x: &TVec<N, D>) -> TVec<u32, D>
// where DefaultAllocator: Alloc<N, D> {
// unimplemented!()
//}

View File

@ -10,7 +10,7 @@ use crate::traits::{Alloc, Dimension};
/// * [`row`](fn.row.html)
/// * [`set_column`](fn.set_column.html)
/// * [`set_row`](fn.set_row.html)
pub fn column<N: Scalar, R: Dimension, C: Dimension>(
pub fn column<N: Scalar + Copy, R: Dimension, C: Dimension>(
m: &TMat<N, R, C>,
index: usize,
) -> TVec<N, R>
@ -27,7 +27,7 @@ where
/// * [`column`](fn.column.html)
/// * [`row`](fn.row.html)
/// * [`set_row`](fn.set_row.html)
pub fn set_column<N: Scalar, R: Dimension, C: Dimension>(
pub fn set_column<N: Scalar + Copy, R: Dimension, C: Dimension>(
m: &TMat<N, R, C>,
index: usize,
x: &TVec<N, R>,
@ -47,7 +47,7 @@ where
/// * [`column`](fn.column.html)
/// * [`set_column`](fn.set_column.html)
/// * [`set_row`](fn.set_row.html)
pub fn row<N: Scalar, R: Dimension, C: Dimension>(m: &TMat<N, R, C>, index: usize) -> TVec<N, C>
pub fn row<N: Scalar + Copy, R: Dimension, C: Dimension>(m: &TMat<N, R, C>, index: usize) -> TVec<N, C>
where DefaultAllocator: Alloc<N, R, C> {
m.row(index).into_owned().transpose()
}
@ -59,7 +59,7 @@ where DefaultAllocator: Alloc<N, R, C> {
/// * [`column`](fn.column.html)
/// * [`row`](fn.row.html)
/// * [`set_column`](fn.set_column.html)
pub fn set_row<N: Scalar, R: Dimension, C: Dimension>(
pub fn set_row<N: Scalar + Copy, R: Dimension, C: Dimension>(
m: &TMat<N, R, C>,
index: usize,
x: &TVec<N, C>,

View File

@ -49,7 +49,7 @@ pub fn packInt4x8(v: &I8Vec4) -> i32 {
unimplemented!()
}
pub fn packRGBM<N: Scalar>(rgb: &TVec3<N>) -> TVec4<N> {
pub fn packRGBM<N: Scalar + Copy>(rgb: &TVec3<N>) -> TVec4<N> {
unimplemented!()
}
@ -155,7 +155,7 @@ pub fn unpackF3x9_E1x5(p: i32) -> Vec3 {
unimplemented!()
}
pub fn unpackHalf<N: Scalar, D: Dimension>(p: TVec<i16, D>) -> TVec<N, D>
pub fn unpackHalf<N: Scalar + Copy, D: Dimension>(p: TVec<i16, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -192,7 +192,7 @@ pub fn unpackInt4x8(p: i32) -> I8Vec4 {
unimplemented!()
}
pub fn unpackRGBM<N: Scalar>(rgbm: &TVec4<N>) -> TVec3<N> {
pub fn unpackRGBM<N: Scalar + Copy>(rgbm: &TVec4<N>) -> TVec3<N> {
unimplemented!()
}

View File

@ -8,7 +8,7 @@ pub fn ceilMultiple<T>(v: T, Multiple: T) -> T {
unimplemented!()
}
pub fn ceilMultiple2<N: Scalar, D: Dimension>(v: &TVec<N, D>, Multiple: &TVec<N, D>) -> TVec<N, D>
pub fn ceilMultiple2<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>, Multiple: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -17,7 +17,7 @@ pub fn ceilPowerOfTwo<IU>(v: IU) -> IU {
unimplemented!()
}
pub fn ceilPowerOfTwo2<N: Scalar, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
pub fn ceilPowerOfTwo2<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -26,7 +26,7 @@ pub fn floorMultiple<T>(v: T, Multiple: T) -> T {
unimplemented!()
}
pub fn floorMultiple2<N: Scalar, D: Dimension>(v: &TVec<N, D>, Multiple: &TVec<N, D>) -> TVec<N, D>
pub fn floorMultiple2<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>, Multiple: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -35,7 +35,7 @@ pub fn floorPowerOfTwo<IU>(v: IU) -> IU {
unimplemented!()
}
pub fn floorPowerOfTwo2<N: Scalar, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
pub fn floorPowerOfTwo2<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -44,12 +44,12 @@ pub fn isMultiple<IU>(v: IU, Multiple: IU) -> bool {
unimplemented!()
}
pub fn isMultiple2<N: Scalar, D: Dimension>(v: &TVec<N, D>,Multiple: N) -> TVec<bool, D>
pub fn isMultiple2<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>,Multiple: N) -> TVec<bool, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
pub fn isMultiple3<N: Scalar, D: Dimension>(v: &TVec<N, D>, Multiple: &TVec<N, D>) -> TVec<bool, D>
pub fn isMultiple3<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>, Multiple: &TVec<N, D>) -> TVec<bool, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -58,7 +58,7 @@ pub fn isPowerOfTwo2<IU>(v: IU) -> bool {
unimplemented!()
}
pub fn isPowerOfTwo<N: Scalar, D: Dimension>(v: &TVec<N, D>) -> TVec<bool, D>
pub fn isPowerOfTwo<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>) -> TVec<bool, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -67,7 +67,7 @@ pub fn roundMultiple<T>(v: T, Multiple: T) -> T {
unimplemented!()
}
pub fn roundMultiple2<N: Scalar, D: Dimension>(v: &TVec<N, D>, Multiple: &TVec<N, D>) -> TVec<N, D>
pub fn roundMultiple2<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>, Multiple: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -76,7 +76,7 @@ pub fn roundPowerOfTwo<IU>(v: IU) -> IU {
unimplemented!()
}
pub fn roundPowerOfTwo2<N: Scalar, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
pub fn roundPowerOfTwo2<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}

View File

@ -7,62 +7,62 @@ use crate::aliases::{
use crate::traits::{Alloc, Dimension, Number};
/// Creates a 2x2 matrix from a slice arranged in column-major order.
pub fn make_mat2<N: Scalar>(ptr: &[N]) -> TMat2<N> {
pub fn make_mat2<N: Scalar + Copy>(ptr: &[N]) -> TMat2<N> {
TMat2::from_column_slice(ptr)
}
/// Creates a 2x2 matrix from a slice arranged in column-major order.
pub fn make_mat2x2<N: Scalar>(ptr: &[N]) -> TMat2<N> {
pub fn make_mat2x2<N: Scalar + Copy>(ptr: &[N]) -> TMat2<N> {
TMat2::from_column_slice(ptr)
}
/// Creates a 2x3 matrix from a slice arranged in column-major order.
pub fn make_mat2x3<N: Scalar>(ptr: &[N]) -> TMat2x3<N> {
pub fn make_mat2x3<N: Scalar + Copy>(ptr: &[N]) -> TMat2x3<N> {
TMat2x3::from_column_slice(ptr)
}
/// Creates a 2x4 matrix from a slice arranged in column-major order.
pub fn make_mat2x4<N: Scalar>(ptr: &[N]) -> TMat2x4<N> {
pub fn make_mat2x4<N: Scalar + Copy>(ptr: &[N]) -> TMat2x4<N> {
TMat2x4::from_column_slice(ptr)
}
/// Creates a 3 matrix from a slice arranged in column-major order.
pub fn make_mat3<N: Scalar>(ptr: &[N]) -> TMat3<N> {
pub fn make_mat3<N: Scalar + Copy>(ptr: &[N]) -> TMat3<N> {
TMat3::from_column_slice(ptr)
}
/// Creates a 3x2 matrix from a slice arranged in column-major order.
pub fn make_mat3x2<N: Scalar>(ptr: &[N]) -> TMat3x2<N> {
pub fn make_mat3x2<N: Scalar + Copy>(ptr: &[N]) -> TMat3x2<N> {
TMat3x2::from_column_slice(ptr)
}
/// Creates a 3x3 matrix from a slice arranged in column-major order.
pub fn make_mat3x3<N: Scalar>(ptr: &[N]) -> TMat3<N> {
pub fn make_mat3x3<N: Scalar + Copy>(ptr: &[N]) -> TMat3<N> {
TMat3::from_column_slice(ptr)
}
/// Creates a 3x4 matrix from a slice arranged in column-major order.
pub fn make_mat3x4<N: Scalar>(ptr: &[N]) -> TMat3x4<N> {
pub fn make_mat3x4<N: Scalar + Copy>(ptr: &[N]) -> TMat3x4<N> {
TMat3x4::from_column_slice(ptr)
}
/// Creates a 4x4 matrix from a slice arranged in column-major order.
pub fn make_mat4<N: Scalar>(ptr: &[N]) -> TMat4<N> {
pub fn make_mat4<N: Scalar + Copy>(ptr: &[N]) -> TMat4<N> {
TMat4::from_column_slice(ptr)
}
/// Creates a 4x2 matrix from a slice arranged in column-major order.
pub fn make_mat4x2<N: Scalar>(ptr: &[N]) -> TMat4x2<N> {
pub fn make_mat4x2<N: Scalar + Copy>(ptr: &[N]) -> TMat4x2<N> {
TMat4x2::from_column_slice(ptr)
}
/// Creates a 4x3 matrix from a slice arranged in column-major order.
pub fn make_mat4x3<N: Scalar>(ptr: &[N]) -> TMat4x3<N> {
pub fn make_mat4x3<N: Scalar + Copy>(ptr: &[N]) -> TMat4x3<N> {
TMat4x3::from_column_slice(ptr)
}
/// Creates a 4x4 matrix from a slice arranged in column-major order.
pub fn make_mat4x4<N: Scalar>(ptr: &[N]) -> TMat4<N> {
pub fn make_mat4x4<N: Scalar + Copy>(ptr: &[N]) -> TMat4<N> {
TMat4::from_column_slice(ptr)
}
@ -75,7 +75,7 @@ pub fn mat2_to_mat3<N: Number>(m: &TMat2<N>) -> TMat3<N> {
}
/// Converts a 3x3 matrix to a 2x2 matrix.
pub fn mat3_to_mat2<N: Scalar>(m: &TMat3<N>) -> TMat2<N> {
pub fn mat3_to_mat2<N: Scalar + Copy>(m: &TMat3<N>) -> TMat2<N> {
TMat2::new(m.m11, m.m12, m.m21, m.m22)
}
@ -90,7 +90,7 @@ pub fn mat3_to_mat4<N: Number>(m: &TMat3<N>) -> TMat4<N> {
}
/// Converts a 4x4 matrix to a 3x3 matrix.
pub fn mat4_to_mat3<N: Scalar>(m: &TMat4<N>) -> TMat3<N> {
pub fn mat4_to_mat3<N: Scalar + Copy>(m: &TMat4<N>) -> TMat3<N> {
TMat3::new(
m.m11, m.m12, m.m13, m.m21, m.m22, m.m23, m.m31, m.m32, m.m33,
)
@ -107,7 +107,7 @@ pub fn mat2_to_mat4<N: Number>(m: &TMat2<N>) -> TMat4<N> {
}
/// Converts a 4x4 matrix to a 2x2 matrix.
pub fn mat4_to_mat2<N: Scalar>(m: &TMat4<N>) -> TMat2<N> {
pub fn mat4_to_mat2<N: Scalar + Copy>(m: &TMat4<N>) -> TMat2<N> {
TMat2::new(m.m11, m.m12, m.m21, m.m22)
}
@ -123,7 +123,7 @@ pub fn make_quat<N: RealField>(ptr: &[N]) -> Qua<N> {
/// * [`make_vec2`](fn.make_vec2.html)
/// * [`make_vec3`](fn.make_vec3.html)
/// * [`make_vec4`](fn.make_vec4.html)
pub fn make_vec1<N: Scalar>(v: &TVec1<N>) -> TVec1<N> {
pub fn make_vec1<N: Scalar + Copy>(v: &TVec1<N>) -> TVec1<N> {
*v
}
@ -137,7 +137,7 @@ pub fn make_vec1<N: Scalar>(v: &TVec1<N>) -> TVec1<N> {
/// * [`vec1_to_vec2`](fn.vec1_to_vec2.html)
/// * [`vec1_to_vec3`](fn.vec1_to_vec3.html)
/// * [`vec1_to_vec4`](fn.vec1_to_vec4.html)
pub fn vec2_to_vec1<N: Scalar>(v: &TVec2<N>) -> TVec1<N> {
pub fn vec2_to_vec1<N: Scalar + Copy>(v: &TVec2<N>) -> TVec1<N> {
TVec1::new(v.x)
}
@ -151,7 +151,7 @@ pub fn vec2_to_vec1<N: Scalar>(v: &TVec2<N>) -> TVec1<N> {
/// * [`vec1_to_vec2`](fn.vec1_to_vec2.html)
/// * [`vec1_to_vec3`](fn.vec1_to_vec3.html)
/// * [`vec1_to_vec4`](fn.vec1_to_vec4.html)
pub fn vec3_to_vec1<N: Scalar>(v: &TVec3<N>) -> TVec1<N> {
pub fn vec3_to_vec1<N: Scalar + Copy>(v: &TVec3<N>) -> TVec1<N> {
TVec1::new(v.x)
}
@ -165,7 +165,7 @@ pub fn vec3_to_vec1<N: Scalar>(v: &TVec3<N>) -> TVec1<N> {
/// * [`vec1_to_vec2`](fn.vec1_to_vec2.html)
/// * [`vec1_to_vec3`](fn.vec1_to_vec3.html)
/// * [`vec1_to_vec4`](fn.vec1_to_vec4.html)
pub fn vec4_to_vec1<N: Scalar>(v: &TVec4<N>) -> TVec1<N> {
pub fn vec4_to_vec1<N: Scalar + Copy>(v: &TVec4<N>) -> TVec1<N> {
TVec1::new(v.x)
}
@ -196,7 +196,7 @@ pub fn vec1_to_vec2<N: Number>(v: &TVec1<N>) -> TVec2<N> {
/// * [`vec2_to_vec2`](fn.vec2_to_vec2.html)
/// * [`vec2_to_vec3`](fn.vec2_to_vec3.html)
/// * [`vec2_to_vec4`](fn.vec2_to_vec4.html)
pub fn vec2_to_vec2<N: Scalar>(v: &TVec2<N>) -> TVec2<N> {
pub fn vec2_to_vec2<N: Scalar + Copy>(v: &TVec2<N>) -> TVec2<N> {
*v
}
@ -210,7 +210,7 @@ pub fn vec2_to_vec2<N: Scalar>(v: &TVec2<N>) -> TVec2<N> {
/// * [`vec2_to_vec2`](fn.vec2_to_vec2.html)
/// * [`vec2_to_vec3`](fn.vec2_to_vec3.html)
/// * [`vec2_to_vec4`](fn.vec2_to_vec4.html)
pub fn vec3_to_vec2<N: Scalar>(v: &TVec3<N>) -> TVec2<N> {
pub fn vec3_to_vec2<N: Scalar + Copy>(v: &TVec3<N>) -> TVec2<N> {
TVec2::new(v.x, v.y)
}
@ -224,7 +224,7 @@ pub fn vec3_to_vec2<N: Scalar>(v: &TVec3<N>) -> TVec2<N> {
/// * [`vec2_to_vec2`](fn.vec2_to_vec2.html)
/// * [`vec2_to_vec3`](fn.vec2_to_vec3.html)
/// * [`vec2_to_vec4`](fn.vec2_to_vec4.html)
pub fn vec4_to_vec2<N: Scalar>(v: &TVec4<N>) -> TVec2<N> {
pub fn vec4_to_vec2<N: Scalar + Copy>(v: &TVec4<N>) -> TVec2<N> {
TVec2::new(v.x, v.y)
}
@ -235,7 +235,7 @@ pub fn vec4_to_vec2<N: Scalar>(v: &TVec4<N>) -> TVec2<N> {
/// * [`make_vec1`](fn.make_vec1.html)
/// * [`make_vec3`](fn.make_vec3.html)
/// * [`make_vec4`](fn.make_vec4.html)
pub fn make_vec2<N: Scalar>(ptr: &[N]) -> TVec2<N> {
pub fn make_vec2<N: Scalar + Copy>(ptr: &[N]) -> TVec2<N> {
TVec2::from_column_slice(ptr)
}
@ -280,7 +280,7 @@ pub fn vec2_to_vec3<N: Number>(v: &TVec2<N>) -> TVec3<N> {
/// * [`vec3_to_vec1`](fn.vec3_to_vec1.html)
/// * [`vec3_to_vec2`](fn.vec3_to_vec2.html)
/// * [`vec3_to_vec4`](fn.vec3_to_vec4.html)
pub fn vec3_to_vec3<N: Scalar>(v: &TVec3<N>) -> TVec3<N> {
pub fn vec3_to_vec3<N: Scalar + Copy>(v: &TVec3<N>) -> TVec3<N> {
*v
}
@ -294,7 +294,7 @@ pub fn vec3_to_vec3<N: Scalar>(v: &TVec3<N>) -> TVec3<N> {
/// * [`vec3_to_vec1`](fn.vec3_to_vec1.html)
/// * [`vec3_to_vec2`](fn.vec3_to_vec2.html)
/// * [`vec3_to_vec4`](fn.vec3_to_vec4.html)
pub fn vec4_to_vec3<N: Scalar>(v: &TVec4<N>) -> TVec3<N> {
pub fn vec4_to_vec3<N: Scalar + Copy>(v: &TVec4<N>) -> TVec3<N> {
TVec3::new(v.x, v.y, v.z)
}
@ -305,7 +305,7 @@ pub fn vec4_to_vec3<N: Scalar>(v: &TVec4<N>) -> TVec3<N> {
/// * [`make_vec1`](fn.make_vec1.html)
/// * [`make_vec2`](fn.make_vec2.html)
/// * [`make_vec4`](fn.make_vec4.html)
pub fn make_vec3<N: Scalar>(ptr: &[N]) -> TVec3<N> {
pub fn make_vec3<N: Scalar + Copy>(ptr: &[N]) -> TVec3<N> {
TVec3::from_column_slice(ptr)
}
@ -367,7 +367,7 @@ pub fn vec3_to_vec4<N: Number>(v: &TVec3<N>) -> TVec4<N> {
/// * [`vec4_to_vec1`](fn.vec4_to_vec1.html)
/// * [`vec4_to_vec2`](fn.vec4_to_vec2.html)
/// * [`vec4_to_vec3`](fn.vec4_to_vec3.html)
pub fn vec4_to_vec4<N: Scalar>(v: &TVec4<N>) -> TVec4<N> {
pub fn vec4_to_vec4<N: Scalar + Copy>(v: &TVec4<N>) -> TVec4<N> {
*v
}
@ -378,18 +378,18 @@ pub fn vec4_to_vec4<N: Scalar>(v: &TVec4<N>) -> TVec4<N> {
/// * [`make_vec1`](fn.make_vec1.html)
/// * [`make_vec2`](fn.make_vec2.html)
/// * [`make_vec3`](fn.make_vec3.html)
pub fn make_vec4<N: Scalar>(ptr: &[N]) -> TVec4<N> {
pub fn make_vec4<N: Scalar + Copy>(ptr: &[N]) -> TVec4<N> {
TVec4::from_column_slice(ptr)
}
/// Converts a matrix or vector to a slice arranged in column-major order.
pub fn value_ptr<N: Scalar, R: Dimension, C: Dimension>(x: &TMat<N, R, C>) -> &[N]
pub fn value_ptr<N: Scalar + Copy, R: Dimension, C: Dimension>(x: &TMat<N, R, C>) -> &[N]
where DefaultAllocator: Alloc<N, R, C> {
x.as_slice()
}
/// Converts a matrix or vector to a mutable slice arranged in column-major order.
pub fn value_ptr_mut<N: Scalar, R: Dimension, C: Dimension>(x: &mut TMat<N, R, C>) -> &mut [N]
pub fn value_ptr_mut<N: Scalar + Copy, R: Dimension, C: Dimension>(x: &mut TMat<N, R, C>) -> &mut [N]
where DefaultAllocator: Alloc<N, R, C> {
x.as_mut_slice()
}

View File

@ -7,7 +7,7 @@ pub fn float_distance<T>(x: T, y: T) -> u64 {
unimplemented!()
}
pub fn float_distance2<N: Scalar>(x: &TVec2<N>, y: &TVec2<N>) -> TVec<u64, U2> {
pub fn float_distance2<N: Scalar + Copy>(x: &TVec2<N>, y: &TVec2<N>) -> TVec<u64, U2> {
unimplemented!()
}

View File

@ -7,22 +7,22 @@ pub fn bitCount<T>(v: T) -> i32 {
unimplemented!()
}
pub fn bitCount2<N: Scalar, D: Dimension>(v: &TVec<N, D>) -> TVec<i32, D>
pub fn bitCount2<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>) -> TVec<i32, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
pub fn bitfieldExtract<N: Scalar, D: Dimension>(Value: &TVec<N, D>, Offset: i32, Bits: i32) -> TVec<N, D>
pub fn bitfieldExtract<N: Scalar + Copy, D: Dimension>(Value: &TVec<N, D>, Offset: i32, Bits: i32) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
pub fn bitfieldInsert<N: Scalar, D: Dimension>(Base: &TVec<N, D>, Insert: &TVec<N, D>, Offset: i32, Bits: i32) -> TVec<N, D>
pub fn bitfieldInsert<N: Scalar + Copy, D: Dimension>(Base: &TVec<N, D>, Insert: &TVec<N, D>, Offset: i32, Bits: i32) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
pub fn bitfieldReverse<N: Scalar, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
pub fn bitfieldReverse<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -31,7 +31,7 @@ pub fn findLSB<IU>(x: IU) -> u32 {
unimplemented!()
}
pub fn findLSB2<N: Scalar, D: Dimension>(v: &TVec<N, D>) -> TVec<i32, D>
pub fn findLSB2<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>) -> TVec<i32, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
@ -40,27 +40,27 @@ pub fn findMSB<IU>(x: IU) -> i32 {
unimplemented!()
}
pub fn findMSB2<N: Scalar, D: Dimension>(v: &TVec<N, D>) -> TVec<i32, D>
pub fn findMSB2<N: Scalar + Copy, D: Dimension>(v: &TVec<N, D>) -> TVec<i32, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
pub fn imulExtended<N: Scalar, D: Dimension>(x: &TVec<i32, D>, y: &TVec<i32, D>, msb: &TVec<i32, D>, lsb: &TVec<i32, D>)
pub fn imulExtended<N: Scalar + Copy, D: Dimension>(x: &TVec<i32, D>, y: &TVec<i32, D>, msb: &TVec<i32, D>, lsb: &TVec<i32, D>)
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
pub fn uaddCarry<N: Scalar, D: Dimension>(x: &TVec<u32, D>, y: &TVec<u32, D>, carry: &TVec<u32, D>) -> TVec<u32, D>
pub fn uaddCarry<N: Scalar + Copy, D: Dimension>(x: &TVec<u32, D>, y: &TVec<u32, D>, carry: &TVec<u32, D>) -> TVec<u32, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
pub fn umulExtended<N: Scalar, D: Dimension>(x: &TVec<u32, D>, y: &TVec<u32, D>, msb: &TVec<u32, D>, lsb: &TVec<u32, D>)
pub fn umulExtended<N: Scalar + Copy, D: Dimension>(x: &TVec<u32, D>, y: &TVec<u32, D>, msb: &TVec<u32, D>, lsb: &TVec<u32, D>)
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}
pub fn usubBorrow<N: Scalar, D: Dimension>(x: &TVec<u32, D>, y: &TVec<u32, D>, borrow: &TVec<u32, D>) -> TVec<u32, D>
pub fn usubBorrow<N: Scalar + Copy, D: Dimension>(x: &TVec<u32, D>, y: &TVec<u32, D>, borrow: &TVec<u32, D>) -> TVec<u32, D>
where DefaultAllocator: Alloc<N, D> {
unimplemented!()
}

View File

@ -40,7 +40,7 @@ where
}
/// The transpose of the matrix `m`.
pub fn transpose<N: Scalar, R: Dimension, C: Dimension>(x: &TMat<N, R, C>) -> TMat<N, C, R>
pub fn transpose<N: Scalar + Copy, R: Dimension, C: Dimension>(x: &TMat<N, R, C>) -> TMat<N, C, R>
where DefaultAllocator: Alloc<N, R, C> {
x.transpose()
}

View File

@ -3,50 +3,50 @@ use na::Scalar;
use crate::aliases::{Vec2, Vec4, UVec2};
pub fn packDouble2x32<N: Scalar>(v: &UVec2) -> f64 {
pub fn packDouble2x32<N: Scalar + Copy>(v: &UVec2) -> f64 {
unimplemented!()
}
pub fn packHalf2x16<N: Scalar>(v: &Vec2) -> u32 {
pub fn packHalf2x16<N: Scalar + Copy>(v: &Vec2) -> u32 {
unimplemented!()
}
pub fn packSnorm2x16<N: Scalar>(v: &Vec2) -> u32 {
pub fn packSnorm2x16<N: Scalar + Copy>(v: &Vec2) -> u32 {
unimplemented!()
}
pub fn packSnorm4x8<N: Scalar>(v: &Vec4) -> u32 {
pub fn packSnorm4x8<N: Scalar + Copy>(v: &Vec4) -> u32 {
unimplemented!()
}
pub fn packUnorm2x16<N: Scalar>(v: &Vec2) -> u32 {
pub fn packUnorm2x16<N: Scalar + Copy>(v: &Vec2) -> u32 {
unimplemented!()
}
pub fn packUnorm4x8<N: Scalar>(v: &Vec4) -> u32 {
pub fn packUnorm4x8<N: Scalar + Copy>(v: &Vec4) -> u32 {
unimplemented!()
}
pub fn unpackDouble2x32<N: Scalar>(v: f64) -> UVec2 {
pub fn unpackDouble2x32<N: Scalar + Copy>(v: f64) -> UVec2 {
unimplemented!()
}
pub fn unpackHalf2x16<N: Scalar>(v: u32) -> Vec2 {
pub fn unpackHalf2x16<N: Scalar + Copy>(v: u32) -> Vec2 {
unimplemented!()
}
pub fn unpackSnorm2x16<N: Scalar>(p: u32) -> Vec2 {
pub fn unpackSnorm2x16<N: Scalar + Copy>(p: u32) -> Vec2 {
unimplemented!()
}
pub fn unpackSnorm4x8<N: Scalar>(p: u32) -> Vec4 {
pub fn unpackSnorm4x8<N: Scalar + Copy>(p: u32) -> Vec4 {
unimplemented!()
}
pub fn unpackUnorm2x16<N: Scalar>(p: u32) -> Vec2 {
pub fn unpackUnorm2x16<N: Scalar + Copy>(p: u32) -> Vec2 {
unimplemented!()
}
pub fn unpackUnorm4x8<N: Scalar>(p: u32) -> Vec4 {
pub fn unpackUnorm4x8<N: Scalar + Copy>(p: u32) -> Vec4 {
unimplemented!()
}

View File

@ -11,16 +11,16 @@ impl<D: DimName + DimMin<D, Output = Self>> Dimension for D {}
/// A number that can either be an integer or a float.
pub trait Number:
Scalar + Ring + Lattice + AbsDiffEq<Epsilon = Self> + Signed + FromPrimitive + Bounded
Scalar + Copy + Ring + Lattice + AbsDiffEq<Epsilon = Self> + Signed + FromPrimitive + Bounded
{
}
impl<T: Scalar + Ring + Lattice + AbsDiffEq<Epsilon = Self> + Signed + FromPrimitive + Bounded>
impl<T: Scalar + Copy + Ring + Lattice + AbsDiffEq<Epsilon = Self> + Signed + FromPrimitive + Bounded>
Number for T
{}
#[doc(hidden)]
pub trait Alloc<N: Scalar, R: Dimension, C: Dimension = U1>:
pub trait Alloc<N: Scalar + Copy, R: Dimension, C: Dimension = U1>:
Allocator<N, R>
+ Allocator<N, C>
+ Allocator<N, U1, R>
@ -50,7 +50,7 @@ pub trait Alloc<N: Scalar, R: Dimension, C: Dimension = U1>:
{
}
impl<N: Scalar, R: Dimension, C: Dimension, T> Alloc<N, R, C> for T where T: Allocator<N, R>
impl<N: Scalar + Copy, R: Dimension, C: Dimension, T> Alloc<N, R, C> for T where T: Allocator<N, R>
+ Allocator<N, C>
+ Allocator<N, U1, R>
+ Allocator<N, U1, C>

View File

@ -253,7 +253,7 @@ where
#[cfg(feature = "serde-serialize")]
impl<N, R, C> Serialize for ArrayStorage<N, R, C>
where
N: Scalar + Serialize,
N: Scalar + Copy + Serialize,
R: DimName,
C: DimName,
R::Value: Mul<C::Value>,
@ -274,7 +274,7 @@ where
#[cfg(feature = "serde-serialize")]
impl<'a, N, R, C> Deserialize<'a> for ArrayStorage<N, R, C>
where
N: Scalar + Deserialize<'a>,
N: Scalar + Copy + Deserialize<'a>,
R: DimName,
C: DimName,
R::Value: Mul<C::Value>,
@ -312,7 +312,7 @@ where
#[cfg(feature = "serde-serialize")]
impl<'a, N, R, C> Visitor<'a> for ArrayStorageVisitor<N, R, C>
where
N: Scalar + Deserialize<'a>,
N: Scalar + Copy + Deserialize<'a>,
R: DimName,
C: DimName,
R::Value: Mul<C::Value>,

View File

@ -781,7 +781,7 @@ impl<N, R, C> Arbitrary for MatrixMN<N, R, C>
where
R: Dim,
C: Dim,
N: Scalar + Arbitrary + Send,
N: Scalar + Copy + Arbitrary + Send,
DefaultAllocator: Allocator<N, R, C>,
Owned<N, R, C>: Clone + Send,
{

View File

@ -138,7 +138,7 @@ where
}
#[cfg(feature = "arbitrary")]
impl<N: Scalar + Arbitrary + Send, D: DimName> Arbitrary for Point<N, D>
impl<N: Scalar + Copy + Arbitrary + Send, D: DimName> Arbitrary for Point<N, D>
where
DefaultAllocator: Allocator<N, D>,
<DefaultAllocator as Allocator<N, D>>::Buffer: Send,

View File

@ -59,7 +59,7 @@ where
}
#[cfg(feature = "arbitrary")]
impl<N: Scalar + Arbitrary, D: DimName> Arbitrary for Translation<N, D>
impl<N: Scalar + Copy + Arbitrary, D: DimName> Arbitrary for Translation<N, D>
where
DefaultAllocator: Allocator<N, D>,
Owned<N, D>: Send,