You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Redirecting to a route which takes a vector parameter throws the following error:
error[E0277]: the trait bound `Vec<i32>: FromUriParam<rocket::http::uri::fmt::Query, _>` is not satisfied
--> src/main.rs:18:31
|
18 | Redirect::to(uri!(test(1, numbers)))
| ^^^^^^^ the trait `FromUriParam<rocket::http::uri::fmt::Query, _>` is not implemented for `Vec<i32>`
|
= help: the following other types implement trait `FromUriParam<P, T>`:
<bool as FromUriParam<P, bool>>
<bool as FromUriParam<P, &'x bool>>
<bool as FromUriParam<P, &'x mut bool>>
<isize as FromUriParam<P, isize>>
<isize as FromUriParam<P, &'x isize>>
<isize as FromUriParam<P, &'x mut isize>>
<i8 as FromUriParam<P, i8>>
<i8 as FromUriParam<P, &'x i8>>
and 149 others
= note: this error originates in the macro `rocket::rocket_internal_uri` which comes from the expansion of the macro `uri` (in Nightly builds, run with -Z macro-backtrace for more info)
According to the Documentation one should only implement the trait FromUriParam if you intend to provide arguments which differ from the parameters in the given function.
After seeking help in the Matrix room I was asked to open an issue regarding this.
Test Case
use rocket::{response::Redirect,Build,Rocket};#[macro_use]externcrate rocket;#[get("/get?<values>")]fnget(values:Vec<i32>) -> String{"hello from get-endpoint.".into()}#[get("/redirect")]fnredirect() -> Redirect{let values:Vec<i32> = vec!(1,2,3);Redirect::to(uri!(get(values)))}#[launch]fnrocket() -> Rocket<Build>{
rocket::build().mount("/",routes![get, redirect])}#[cfg(test)]mod test {usesuper::rocket;use rocket::local::blocking::Client;use rocket::http::Status;#[test]fnhello_world(){let client = Client::tracked(rocket()).expect("valid rocket instance");letmut response = client.get(uri!(super::redirect)).dispatch();assert_eq!(response.status(), Status::SeeOther);}}
Log Output
ROCKET_LOG_LEVEL=debug cargo test
Compiling rocket-test v0.1.0 (/tmp/rocket-test)
error[E0277]: the trait bound `Vec<i32>: FromUriParam<rocket::http::uri::fmt::Query, _>` is not satisfied
--> src/main.rs:13:27
|
13 | Redirect::to(uri!(get(values)))
| ^^^^^^ the trait `FromUriParam<rocket::http::uri::fmt::Query, _>` is not implemented for`Vec<i32>`|
= help: the following other types implement trait `FromUriParam<P, T>`:
<bool as FromUriParam<P, bool>><bool as FromUriParam<P, &'x bool>> <bool as FromUriParam<P, &'x mut bool>><isize as FromUriParam<P, isize>><isize as FromUriParam<P, &'x isize>> <isize as FromUriParam<P, &'x mut isize>><i8 as FromUriParam<P, i8>><i8 as FromUriParam<P, &'x i8>> and 149 others = note: this error originates in the macro `rocket::rocket_internal_uri` which comes from the expansion of the macro `uri` (in Nightly builds, run with -Z macro-backtrace for more info)For more information about this error, try `rustc --explain E0277`.error: could not compile `rocket-test` (bin "rocket-test" test) due to previous error
Additional Context
No response
System Checks
My bug report relates to functionality.
I have tested against the latest Rocket release or a recent git commit.
I have tested against the latest stable rustc toolchain.
I was unable to find this issue previously reported.
The text was updated successfully, but these errors were encountered:
Rocket Version
0.5.0
Operating System
NixOS 23.11
Rust Toolchain Version
rustc 1.76.0
What happened?
Redirecting to a route which takes a vector parameter throws the following error:
According to the Documentation one should only implement the trait
FromUriParam
if you intend to provide arguments which differ from the parameters in the given function.After seeking help in the Matrix room I was asked to open an issue regarding this.
Test Case
Log Output
Additional Context
No response
System Checks
rustc
toolchain.The text was updated successfully, but these errors were encountered: