小编Cha*_*eng的帖子

拉链两条链后如何反转

我有以下不编译的代码.

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

8
推荐指数
1
解决办法
199
查看次数

标签 统计

rust ×1