【发布时间】:2019-07-05 02:25:29
【问题描述】:
我正在尝试在 Warp 中使用可变路径。我试过这个:
use uuid::Uuid;
use warp::{self, Filter};
fn main() {
let uuid = Uuid::new_v4();
println!("{}", uuid);
let hello = warp::path(&uuid.to_string()).map(|| "hello world");
warp::serve(hello).run(([127, 0, 0, 1], 8080));
}
但我得到了错误:
error[E0716]: temporary value dropped while borrowed
--> src/main.rs:9:29
|
9 | let hello = warp::path(&uuid.to_string()).map(|| "hello world");
| ------------^^^^^^^^^^^^^^^^- - temporary value is freed at the end of this statement
| | |
| | creates a temporary which is freed while still in use
| argument requires that borrow lasts for `'static`
让路径参数具有'static 生命周期的最佳方法是什么?
【问题讨论】:
-
也许你应该问你的问题in this form 让人们轻松测试你的代码