I'm trying to pass an ndarray into another function but I'm unsure what type I should give. The docs say that the equivalent of Numpy's np.ndarray
type is the ArrayBase<S, D>
type, but when I try to use that in the function signature I'm unable to specify the dimension. Would appreciate any help.
Code -
use rand::Rng;
use ndarray::prelude::*;
fn takes_array(&mut lattice: ArrayBase<i32, 2>){
}
fn main() {
let mut rng = rand::thread_rng();
let mut lattice = Array::from_shape_fn((100, 100), |x| [-1, 1][rng.gen_range(0..1)]);
}
Error -
Compiling metropolis v0.1.0 (/home/cocoafedora/Documents/Code/RustLearning/metropolis)
error[E0747]: constant provided when a type was expected
--> src/main.rs:4:45
|
4 | fn takes_array(&mut lattice: ArrayBase<i32, 2>){
| ^
For more information about this error, try `rustc --explain E0747`.
error: could not compile `metropolis` due to previous error