![](/img/trans.png)
[英]Why do I get "no method named `join` found for type `[usize]` in the current scope"?
[英]Rust: no method named `iter` found for struct `std::ops::Range<usize>` in the current scope
你能告诉我编译器在抱怨什么吗? 我不明白。
numcities is a usize
let mut path = (0..graph.numcities).chain([0].iter()).collect();
error[E0599]: no method named `iter` found for struct `std::ops::Range<usize>` in the current scope
--> tsp-arekbulski-01-random.rs:230:39
|
230 | let mut path = (0..graph.numcities).iter().chain([0].iter()).collect();
| ^^^^ method not found in `std::ops::Range<usize>`
我相信这是解决方案/解决方法:
let mut path: Vec::<usize> = (0..graph.numcities).collect::<Vec::<usize>>().iter().chain([0].iter()).map(|x| *x).collect();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.