nalgebra
nalgebra copied to clipboard
additional means of construction for constants
This compiles with nalgebra 0.29.0:
const ZERO: Vector3<f64> = Vector3::new(0.0, 0.0, 0.0);
but these do not:
const ZERO: Vector3<f64> = Vector3::zeros();
const ZERO: Vector3<f64> = Vector3::from_row_slice(&[0.0, 0.0, 0.0]);
// error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
It would be handy if additional means of construction (e.g. zeros) could be used for constants.
Unfortunately the user guide has not yet been updated, but the macros vector!
and matrix!
should do what you want:
const ZERO: Vector3<f64> = vector![0.0, 0.0, 0.0];
Hope that helps!