-
-
Save silverjam/254c5b6ecd526726e17f89135710034e to your computer and use it in GitHub Desktop.
serde yaml bug
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
[package] | |
name = "yamltest" | |
version = "0.1.0" | |
edition = "2021" | |
[[bin]] | |
name = "yamltest" | |
path = "main.rs" | |
[dependencies] | |
serde = { version = "1", features = ["derive"] } | |
serde_yaml = "0.9" |
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 serde::Deserialize; | |
#[derive(Debug, Deserialize)] | |
struct Frob { | |
foo: u32, | |
} | |
fn main() { | |
let value: serde_yaml::Value = serde_yaml::from_str( | |
r#" | |
--- | |
"foo": !!int |- | |
7200 | |
"# | |
).unwrap(); | |
println!("{:?}", value); | |
let frob: Frob = serde_yaml::from_str( | |
r#" | |
--- | |
"foo": !!int |- | |
7200 | |
"# | |
).unwrap(); | |
println!("{:?}", frob); | |
println!("frob.foo = {}", frob.foo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment