I’m transitioning some code to use nalgebra. I ran into issues while moving the Strategy for generating random Vector3 data. The end goal is to get prop test up and running for random Vector3 data.
I have the following code:
pub fn st_vec3<T>(s: impl Strategy<Value = T> + Clone) -> impl Strategy<Value = Vector3<T>>
where
T: Arbitrary + Scalar,
{
(s.clone(), s.clone(), s.clone()).prop_map(|(x, y, z)| Vector3::new(x, y, z))
}
This gives the following error:
error[E0271]: type mismatch resolving `<[closure@src/render/ray.rs:51:52: 51:85] as std::ops::FnOnce<((T, T, T),)>>::Output == na::Matrix<T, na::U3, na::U1, <na::DefaultAllocator as na::allocator::Allocator<T, na::U3>>::Buffer>`
--> src/render/ray.rs:47:63
|
47 | pub fn st_vec3<T>(s: impl Strategy<Value = T> + Clone) -> impl Strategy<Value = Vector3<T>>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `na::ArrayStorage`, found associated type
|
= note: expected type `na::Matrix<_, _, _, na::ArrayStorage<T, na::U3, na::U1>>`
found type `na::Matrix<_, _, _, <na::DefaultAllocator as na::allocator::Allocator<T, na::U3>>::Buffer>`
= note: required because of the requirements on the impl of `proptest::strategy::traits::Strategy` for `proptest::strategy::map::Map<(impl Strategy<Value = T> + Clone, impl Strategy<Value = T> + Clone, impl Strategy<Value = T> + Clone), [closure@src/render/ray.rs:51:52: 51:85]>`
= note: the return type of a function must have a statically known size
error: aborting due to previous error
It seems like the issues is that the storage types mismatch here. I haven’t been able to figure out much about why that is.