Serde-toml has quite the interesting feature: they support emitting spans for the underlying object it returns. For instance,
#[macro_use]
extern crate serde_derive;
extern crate toml;
use toml::spanned::Spanned;
#[derive(Deserialize)]
struct Udoprog {
s: Spanned<String>,
}
fn main() {
let t = "s = \"udoprog\"\n";
let u: Udoprog = toml::from_str(t).unwrap();
assert_eq!(u.s.start, 4);
assert_eq!(u.s.end, 13);
}
This allows users of serde-toml to provide their own high-level diagnostics. For instance, it could be combined with a crate like codespan to provide diagnostics fairly similar to rustc', without having to write our own parsers.
It'd be nice for serde-yaml to provide a similar feature.
I would prefer not to have this in this library, but it would be reasonable for someone else to implement a more fully featured YAML library which implements this.
Serde-toml has quite the interesting feature: they support emitting spans for the underlying object it returns. For instance,
This allows users of serde-toml to provide their own high-level diagnostics. For instance, it could be combined with a crate like codespan to provide diagnostics fairly similar to rustc', without having to write our own parsers.
It'd be nice for
serde-yaml
to provide a similar feature.