mirror of
https://github.com/rwf2/Rocket.git
synced 2024-12-27 21:02:41 +00:00
9177b20ff1
This commit implements a workaround for an [issue within rustc]. The problem showed itself when using e.g. a `Vec<&str>` argument in an async route handler (but not `&str`), which resulted in a "implementation of `FromForm` is not general enough" error. The workaround itself works by gathering all invocations of `FromForm`'s methods inside a block without any `.await` points [ref]. [issue within rustc]: https://github.com/rust-lang/rust/issues/69663 [ref]: https://github.com/rust-lang/rust/issues/57478#issuecomment-501186084
26 lines
487 B
Rust
26 lines
487 B
Rust
#![allow(dead_code)]
|
|
|
|
#[macro_use] extern crate rocket;
|
|
use rocket::http::uri::Origin;
|
|
use rocket::request::Request;
|
|
|
|
async fn noop() { }
|
|
|
|
#[get("/")]
|
|
async fn hello(_origin: &Origin<'_>) -> &'static str {
|
|
noop().await;
|
|
"Hello, world!"
|
|
}
|
|
|
|
#[get("/repeated_query?<sort>")]
|
|
async fn repeated_query(sort: Vec<&str>) -> &str {
|
|
noop().await;
|
|
sort[0]
|
|
}
|
|
|
|
#[catch(404)]
|
|
async fn not_found(req: &Request<'_>) -> String {
|
|
noop().await;
|
|
format!("{} not found", req.uri())
|
|
}
|