SHARE
TWEET

Untitled

a guest Sep 16th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #[macro_use]
  2. extern crate serde_derive;
  3.  
  4. #[derive(Debug, Deserialize)]
  5. pub struct SignUpParams<'a> {
  6.     pub username: &'a str,
  7.     pub password: &'a str,
  8. }
  9.  
  10. fn create(d: &[u8]) -> SignUpParams {
  11.     serde_json::from_slice::<SignUpParams>(d).unwrap()
  12. }
  13.  
  14. fn main() {
  15.     let s = String::from("{\"username\":\"abc\",\"password\":\"123\"}");
  16.     let _ = create(s.as_bytes());
  17.     println!("Hello, world!");
  18. }
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