首页 > 解决方案 > 为什么shiplift 0.6 中的类型说`std::future::Future` 不满足?

问题描述

我正在使用该shiplift库对 Rust 进行试验,并尝试运行 repo 中提供的基本示例。

use shiplift::Docker;

#[tokio::main]
async fn main() {
    let docker = Docker::new();

    match docker.info().await {
        Ok(info) => println!("info {:?}", info),
        Err(e) => eprintln!("Error: {}", e),
    }
}

当我尝试编译时,出现错误:

   Compiling foo v0.1.0 (/Users/cbourne/development/rust/foo)
error[E0277]: the trait bound `impl futures::future::Future: std::future::Future` is not satisfied
 --> src/main.rs:7:11
  |
7 |     match docker.info().await {
  |           ^^^^^^^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `impl futures::future::Future`
  |
  = note: required by `std::future::Future::poll`

我的Cargo.toml文件如下所示:

[package]
name = "foo"
version = "0.1.0"
authors = ["carlskii"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
shiplift = "0.6"
tokio = { version = "0.2.22", features = ["macros", "tcp", "dns", "io-util"] }
log = "0.4.0"
env_logger = "0.7.1"
futures = "0.3.1"

标签: rust

解决方案


推荐阅读