我有以下不编译的代码.
fn main() {
let a =
"123"
.chars()
.chain("4566".chars())
.zip(
"bbb"
.chars()
.chain("yyy".chars()))
.rev()
.map(|x, y| y)
.collect::<String>();
println!("Hello, world! {}", a);
}
Run Code Online (Sandbox Code Playgroud)
得到如下错误:
src/main.rs:37:10: 37:15 error: the trait `core::iter::ExactSizeIterator` is not implemented for the type `core::iter::Chain<core::str::Chars<'_>, core::str::Chars<'_>>` [E0277]
src/main.rs:37 .rev()
^~~~~
src/main.rs:37:10: 37:15 error: the trait `core::iter::ExactSizeIterator` is not implemented for the type `core::iter::Chain<core::str::Chars<'_>, core::str::Chars<'_>>` [E0277]
src/main.rs:37 .rev()
^~~~~
src/main.rs:38:10: 38:23 error: type `core::iter::Rev<core::iter::Zip<core::iter::Chain<core::str::Chars<'_>, core::str::Chars<'_>>, core::iter::Chain<core::str::Chars<'_>, core::str::Chars<'_>>>>` does not implement any method in scope named `map`
src/main.rs:38 .map(|x, …Run Code Online (Sandbox Code Playgroud) rust ×1