Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. struct IsPresent(bool);
  2.  
  3. impl FromFormValue<'v> for IsPresent {
  4. type Error = ();
  5. fn from_form_value(form_value: &'v RawStr) -> Result<Self, Self::Error> {
  6. // from_form_value is only called when a key is present
  7.  
  8. Ok(IsPresent(true))
  9. }
  10.  
  11. fn default() -> Option<Self> {
  12. // default is called after all parameters have been looked at
  13. // and the given key was found missing. Without default(),
  14. // the missing key would be treated as an error.
  15. Some(IsPresent(false))
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement