-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FromForm Option<Result> with custom type #2801
Comments
This is exactly what's expected. Maybe you want |
Actually, #[get("/login?<p>")]
pub async fn login(p: Result<'_, Option<usize>>) -> String {
format!("{p:?}")
}
#[launch]
fn rocket() -> _ {
rocket::build()
.mount("/", routes![login])
}
#[test]
fn test_options() {
let client = Client::tracked(rocket()).unwrap();
let response = client.get("/login?p=a").dispatch();
let res = response.into_string().unwrap();
assert!(res.starts_with("Err"), "Value: {res}");
} When run, the form deserializes to |
That's fair. It's something I've considered changing as well. I believe this is the way that |
Note that #2543 exists already for the same issue. Let's manage this there. |
Rocket Version
0.5.1
Operating System
Linux
Rust Toolchain Version
rustc 1.79.0-nightly (0d8b3346a 2024-04-14)
What happened?
Create a form and derive FromForm with a field
Option<Result<T>>
whereT
is a custom type. Submit the form with nothing for that field, and the field is parsed as Some(Missing
error) instead ofNone
.Test Case
Log Output
Additional Context
I don't think this is a runtime bug so haven't provided complete logs... it seems like it's a failure in parsing that no debug logs could help with.
System Checks
rustc
toolchain.The text was updated successfully, but these errors were encountered: