tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test.rs (1037B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 pub static ELEMENT_KEY: &'static str = "element-6066-11e4-a52e-4f735466cecf";
      6 
      7 pub fn assert_ser_de<T>(data: &T, json: serde_json::Value)
      8 where
      9    T: std::fmt::Debug,
     10    T: std::cmp::PartialEq,
     11    T: serde::de::DeserializeOwned,
     12    T: serde::Serialize,
     13 {
     14    assert_eq!(serde_json::to_value(data).unwrap(), json);
     15    assert_eq!(data, &serde_json::from_value::<T>(json).unwrap());
     16 }
     17 
     18 #[allow(dead_code)]
     19 pub fn assert_ser<T>(data: &T, json: serde_json::Value)
     20 where
     21    T: std::fmt::Debug,
     22    T: std::cmp::PartialEq,
     23    T: serde::Serialize,
     24 {
     25    assert_eq!(serde_json::to_value(data).unwrap(), json);
     26 }
     27 
     28 pub fn assert_de<T>(data: &T, json: serde_json::Value)
     29 where
     30    T: std::fmt::Debug,
     31    T: std::cmp::PartialEq,
     32    T: serde::de::DeserializeOwned,
     33 {
     34    assert_eq!(data, &serde_json::from_value::<T>(json).unwrap());
     35 }