Created
June 27, 2017 21:43
-
-
Save saarw/d18770d209f156ddb53c9e366cd22abd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use erased_serde; | |
use serde_json; | |
#[derive(Serialize)] | |
struct Event { | |
data_point: usize | |
} | |
#[derive(Serialize)] | |
struct Batch { | |
field1: String, | |
field2: String, | |
events: Vec<Box<erased_serde::Serialize>> | |
} | |
fn serialize_batch(events: Vec<Box<erased_serde::Serialize>>) -> String { | |
serde_json::to_string(&Batch{field1: "a".to_string(), field2: "b".to_string(), events: events}).unwrap() | |
} | |
#[test] | |
fn test_serialize() { | |
assert!(serialize_batch(vec!(Box::new(Event{data_point: 13}))).len() > 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment