Skip to content
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

Change behavior for empty values when deserializing an option #13

Open
jplatte opened this issue Jan 27, 2024 · 1 comment
Open

Change behavior for empty values when deserializing an option #13

jplatte opened this issue Jan 27, 2024 · 1 comment

Comments

@jplatte
Copy link
Owner

jplatte commented Jan 27, 2024

Currently, the following two forms get the foo field deserialized to None given the input foo=:

#[derive(Deserialize)]
struct FormA {
    foo: Option<String>,
}

#[derive(Deserialize)]
struct FormB {
   foo: Option<Vec<String>>,
}

I think the most reasonable output would instead be an empty string (as the only list element) wrapped in Some for both forms.

What might also be relevant: I think the same forms with String replaced by f64 should produce foo: None for FormA and a deserialization error for FormB. I think both should already be the case.

This is a breaking change, so if implemented I will publish it as part of serde_html_form 0.3.0.

@jplatte
Copy link
Owner Author

jplatte commented Sep 27, 2024

Should also when working on this consider testing ?foo separately from ?foo=. Both should produce an empty string (see discussion in #21).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant