Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct IsPresent(bool);
- impl FromFormValue<'v> for IsPresent {
- type Error = ();
- fn from_form_value(form_value: &'v RawStr) -> Result<Self, Self::Error> {
- // from_form_value is only called when a key is present
- Ok(IsPresent(true))
- }
- fn default() -> Option<Self> {
- // default is called after all parameters have been looked at
- // and the given key was found missing. Without default(),
- // the missing key would be treated as an error.
- Some(IsPresent(false))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement