1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
pub extern crate deadpool;
pub mod common;
pub use common::*;
pub mod db;
pub mod error;
#[macro_use]
pub mod ext;
pub mod io;
pub mod net;
pub mod pool;
pub mod rt;
pub mod time;
pub mod types;
pub mod util;
pub use error::*;
pub use util::*;
#[cfg(test)]
mod test {
use std::collections::HashMap;
#[test]
fn test_ser_ref() {
#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub struct A {
pub name: String,
}
let a = A {
name: "sss".to_string(),
};
let mut m = HashMap::new();
m.insert(1, 2);
let v = rbs::to_value(a).unwrap();
println!("v: {}", v);
let s: A = rbs::from_value(v).unwrap();
println!("s:{:?}", s);
}
#[test]
fn test_ext() {
#[derive(Debug, PartialEq, serde::Serialize, serde::Deserialize)]
struct ExtStruct(String);
let arg = ExtStruct {
0: "saasdfas".to_string(),
};
let v = rbs::to_value(&arg).unwrap();
println!("{:?}", v);
let ext: ExtStruct = rbs::from_value(v).unwrap();
assert_eq!(arg, ext);
}
}