我想使用名为 warp 的第三方库编译一个简单的 rust 程序:
[package]
name = "hello-world-warp"
version = "0.1.0"
[dependencies]
warp = "0.1.18"
在src/main.rs
:
use warp::{self, path, Filter};
fn main() {
// GET /hello/warp => 200 OK with body "Hello, warp!"
let hello = warp::path!("hello" / String)
.map(|name| format!("Hello, {}!", name));
warp::serve(hello)
.run(([127, 0, 0, 1], 3030));
}
当我运行时,cargo build
我看到它下载了 warp 和许多传递依赖项,然后我得到了错误:
Compiling hello-world-warp v0.1.0 (<path>) error[E0432]: unresolved import `warp`
--> src/main.rs:3:12
|
3 | use warp::{self, path, Filter};
| ^^^^ no `warp` in the root
error: cannot find macro `path!` in this scope
我浏览了关于模块和板条箱的各种文档。在这个简单的场景中我做错了什么?