This code can be easily fixed by adding an & in the call to contains.
fn main() {
let haystack = [&["A1", "A2"][..], &["B1", "B2"], &["C1", "C2"]];
let needle: &[&str] = &["D1", "D2"];
println!("{}", haystack.contains(needle));
}
(Playground)
Errors:
Compiling playground v0.0.1 (/playground)
error[E0308]: mismatched types
--> src/main.rs:4:38
|
4 | println!("{}", haystack.contains(needle));
| ^^^^^^ expected `&[&str]`, found slice `[&str]`
|
= note: expected reference `&&[&str]`
found reference `&[&str]`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.
This code can be easily fixed by adding an
&in the call tocontains.(Playground)
Errors: