Reputation: 45
I have a problem with the following code
extern crate num;
extern crate rustfft;
use rustfft::num_complex::Complex;
use rustfft::num_traits::Zero;
pub fn ct_fft(input: &Vec<f64>, sampling: u32) {
let data_size = input.len();
let mut input_array: Vec<Complex<f64>> = Vec::with_capacity(data_size);
let fft = rustfft::FFTplanner::new(false).plan_fft(data_size as usize);
for v in input {
input_array.push(Complex { re: *v, im: 0.0 });
}
}
I get the error:
error[E0283]: type annotations required: cannot resolve `_: rustfft::FFTnum` --> src/ctdsp.rs:19:15 | 19 | let fft = rustfft::FFTplanner::new(false).plan_fft(data_size as usize); | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: required by `<rustfft::FFTplanner<T>>::new` error: aborting due to previous error
I don't understand why I got this error; I was using RustFFT earlier and it worked with no problems and I'm using it exactly the same way. I cannot find any information about this error in regard to RustFFT.
Rust version:
╰─$ rustc --version rustc 1.26.0-nightly (9c9424de5 2018-03-27)
Upvotes: 1
Views: 285
Reputation: 59125
The problem (from your comments) is that you weren't using fft
. Rust can infer types, but it can only do so if there's enough context. If you never use fft
, the compiler doesn't have enough information to work out what the complete type is supposed to be.
Remember, every variable in Rust has a single, complete type. It's just that in some cases, Rust can work it out by itself and lets you omit the type. This is not one of those cases.
Upvotes: 1