SHARE
TWEET

Untitled

a guest Apr 24th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top