I'm confused about this:
use itertools::Itertools; // 0.10.0
fn main() {
let combos = ["a", "b", "c"].iter().combinations(2).collect::<Vec<_>>();
println!("{:#?}", combos[0].join(""));
}
error[E0599]: the method `join` exists for struct `Vec<&&str>`, but its trait bounds were not satisfied
--> src/main.rs:5:33
|
5 | println!("{:#?}", combos[0].join(""));
| ^^^^ method cannot be called on `Vec<&&str>` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`Vec<&&str>: Iterator`
which is required by `Vec<&&str>: Itertools`
`<[&&str] as Join<_>>::Output = _`
`[&&str]: Iterator`
which is required by `[&&str]: Itertools`
- Why is
combos[0]
aVec<&&str>
, rather than aVec<&str>
? - What are the unsatisfied trait bounds here?
- How do I resolve the error?
I'm sure these answers are derivable from the book, but I was hoping not to have to read the whole book to write this trivial program. Perhaps one can not merely dabble in Rust ...