SHARE
TWEET

Untitled

a guest Oct 14th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // extern crate serde;
  2.  
  3. use serde::de::{self, Deserializer};
  4. use serde::Deserialize;
  5.  
  6. struct Duration {
  7.     secs: u64,
  8.     nanos: u32,
  9. }
  10.  
  11. impl<'de> de::Deserialize<'de> for Duration {
  12.     fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
  13.     where
  14.         D: Deserializer<'de>,
  15.     {
  16.         // Do at least one of these to compile successfully:
  17.         // - add `extern crate serde;`
  18.         // - move `Field` and its derive outside this impl block
  19.         // - switch to the manual implementation below
  20.         #[derive(Deserialize)]
  21.         enum Field {
  22.             Secs,
  23.             Nanos,
  24.         }
  25.  
  26.         // enum Field { Secs, Nanos };
  27.         //
  28.         // impl<'de> Deserialize<'de> for Field {
  29.         //     fn deserialize<D>(deserializer: D) -> Result<Field, D::Error>
  30.         //     where
  31.         //         D: Deserializer<'de>,
  32.         //     {
  33.         //         unimplemented!();
  34.         //     }
  35.         // }
  36.  
  37.         unimplemented!();
  38.     }
  39. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top