We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'm using FormData to get some input values, and convert these values to i64. currently I used this method to reduce duplicate code:
#[derive(Debug, Default)] struct Number(i64); impl TryFrom<Option<FormDataEntry>> for Number { type Error = (); fn try_from(form: Option<FormDataEntry>) -> Result<Self, Self::Error> { let form = form.unwrap(); match form { FormDataEntry::String(s) => Ok(Number(s.parse().expect("Error: Not a number!"))), _ => Err(()), } } } fn get_num(form: &FormData, name: &str) -> i64 { Number::try_from(form.get(name)).unwrap().0 }
I'm not familiar with Rust, and I feel this code is ugly.
I think it's better to add similar functions in FormData. Then we can get the values easily. e.g.
form.get(name).to_i64() form.get(name).to_string() ...
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'm using FormData to get some input values, and convert these values to i64.
currently I used this method to reduce duplicate code:
I'm not familiar with Rust, and I feel this code is ugly.
I think it's better to add similar functions in FormData. Then we can get the values easily.
e.g.
The text was updated successfully, but these errors were encountered: