aya-rs/book

examples/myapp-02 'cargo build' fails

Closed this issue · 1 comments

Running cargo build in examples/myapp-02 fails:

   Compiling myapp v0.1.0 (/home/dmitris
![Screenshot 2022-01-14 at 13 18 35](https://user-images.githubusercontent.com/31205/149514426-0c779154-177b-4f14-baf3-d3d5d1493c22.png)
![Screenshot 2022-01-14 at 13 18 35](https://user-images.githubusercontent.com/31205/149514485-be4ff808-d901-4ee0-8b87-5d73df53f785.png)
/dev/hack/gh/aya-rs/book/examples/myapp-02/myapp)
error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in an async block that returns `Result`
  --> myapp/src/main.rs:31:49
   |
18 |   async fn main() -> Result<(), anyhow::Error> {
   |  ______________________________________________-
19 | |     let path = match env::args().nth(1) {
20 | |         Some(iface) => iface,
21 | |         None => panic!("not path provided"),
...  |
31 | |     let probe: &mut Xdp = bpf.program_mut("xdp")?.try_into()?;
   | |                                                 ^ use `.ok_or(...)?` to provide an error compatible with `Result<(), anyhow::Error>`
...  |
60 | |     Ok::<_, anyhow::Error>(())
61 | | }
   | |_- this function returns a `Result`
   |
   = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<(), anyhow::Error>`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `myapp` due to previous error