SHARE
TWEET

Untitled

a guest Jan 19th, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::cmp::PartialEq;
  2. use snapshot_derive::Snapshot;
  3.  
  4. #[derive(Snapshot, Debug, PartialEq)]
  5. #[snapshot(version = 1)]
  6. struct Test_v1 {
  7.     #[snapshot(default = 100)]
  8.     field1: u32,
  9.     #[snapshot(default = "default")]
  10.     field2: String,
  11.     // Default value for this field is infered as an empty vec.
  12.     field3: Vec<u8>
  13. }
  14.  
  15. #[derive(Snapshot, Debug, PartialEq)]
  16. #[snapshot(version = 2)]
  17. struct Test_v2 {
  18.     field1: u32,
  19.     field2: String,
  20. }
  21.  
  22. #[derive(Snapshot, Debug, PartialEq)]
  23. #[snapshot(version = 3)]
  24. struct Test_v3 {
  25.     field1: u32,
  26.     field2: String,
  27.     #[snapshot(default = true)]
  28.     is_cool: bool,
  29. }
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