serde-hex
serde-hex copied to clipboard
Add support for deserialization of owned values
Resolves #7.
There is some duplication between the visitors so there is potential for follow-up work. The feature works however and is tested with 2 additional tests I added.
Let me know what you think!
Many thanks for this patch!
I have spend a lot of time trying to figure out why this toy example:
use serde::{Deserialize};
use serde_hex::{SerHex, CompactPfx};
#[derive(Debug, Deserialize)]
struct Foo {
#[serde(with = "SerHex::<CompactPfx>")]
bar: u32
}
const INI: &str = r#"bar = 0x42"#;
fn main() {
let foo: Foo = serde_ini::from_str(INI).unwrap();
println!("{:?}", foo);
}
Was providing the following result:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom("invalid type: string \"0x42\", expected a borrowed byte array")', src/main.rs:17:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Cheers!
Awesome! Exactly what i needed! @fspmarshall Any chance to merge this soon?
ping @fspmarshall