Julio Biason
3 years ago
4 changed files with 111 additions and 0 deletions
@ -0,0 +1,71 @@
|
||||
# This file is automatically @generated by Cargo. |
||||
# It is not intended for manual editing. |
||||
[[package]] |
||||
name = "proc-macro2" |
||||
version = "1.0.27" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" |
||||
dependencies = [ |
||||
"unicode-xid", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "quote" |
||||
version = "1.0.9" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" |
||||
dependencies = [ |
||||
"proc-macro2", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "serde" |
||||
version = "1.0.126" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" |
||||
|
||||
[[package]] |
||||
name = "serde_derive" |
||||
version = "1.0.126" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" |
||||
dependencies = [ |
||||
"proc-macro2", |
||||
"quote", |
||||
"syn", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "serdedyn" |
||||
version = "0.1.0" |
||||
dependencies = [ |
||||
"serde", |
||||
"serde_derive", |
||||
"toml", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "syn" |
||||
version = "1.0.73" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" |
||||
dependencies = [ |
||||
"proc-macro2", |
||||
"quote", |
||||
"unicode-xid", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "toml" |
||||
version = "0.5.8" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" |
||||
dependencies = [ |
||||
"serde", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "unicode-xid" |
||||
version = "0.2.2" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" |
@ -0,0 +1,10 @@
|
||||
[package] |
||||
name = "serdedyn" |
||||
version = "0.1.0" |
||||
authors = ["Julio Biason <julio.biason@pm.me>"] |
||||
edition = "2018" |
||||
|
||||
[dependencies] |
||||
toml = "0.5" |
||||
serde = "*" |
||||
serde_derive = "*" |
@ -0,0 +1,3 @@
|
||||
# serdedyn |
||||
|
||||
Checking if Serde can work with `dyn` things. |
@ -0,0 +1,27 @@
|
||||
use serde_derive::Deserialize; |
||||
use serde_derive::Serialize; |
||||
|
||||
trait Marker {} |
||||
|
||||
#[derive(Serialize, Deserialize, Debug)] |
||||
struct AsString { |
||||
value: String, |
||||
} |
||||
impl Marker for AsString {} |
||||
|
||||
#[derive(Serialize, Deserialize, Debug)] |
||||
struct AsU8 { |
||||
value: u8, |
||||
} |
||||
impl Marker for AsU8 {} |
||||
|
||||
fn main() { |
||||
let mut contents: Vec<Box<dyn Marker>> = Vec::new(); |
||||
contents.push(Box::new(AsString { |
||||
value: "Some value".into(), |
||||
})); |
||||
contents.push(Box::new(AsU8 { value: 2 })); |
||||
|
||||
let convered = toml::to_string(&contents).unwrap(); |
||||
println!("{}", convered); |
||||
} |
Loading…
Reference in new issue