deser icon indicating copy to clipboard operation
deser copied to clipboard

Spanned elements

Open ratmice opened this issue 3 years ago • 1 comments

One thing which might be worth thinking about is whether the difference in data model allow deser to implement Spanned, In the following comment dtolnay says serde's model is not necessarily byte oriented. https://github.com/serde-rs/serde/issues/1811#issuecomment-629595336

if deser's model is, perhaps it could be worth including.

A few serde serializer/deserializer implementations implement it directly.

https://crates.io/crates/json-spanned-value https://docs.rs/toml/latest/toml/struct.Spanned.html

But even with these, there are for instance odd interactions with Default. Presumably a span for a default element could be one of None for an optional span type, or alternately the Span of any enclosing element?

Anyhow, it seemed worth thinking about perhaps, but doesn't seem to be essential.

ratmice avatar Apr 06 '22 09:04 ratmice

The idea originally was that you can do things like Spanned through the context interface by using standardized types to attach information from the deserializer into the deserialization system. Unfortunately what I'm noticing as part of the existing implementation is that this is expensive with dynamic dispatch and I have not found a good way around this yet.

I do not want to give up on type erasure and dynamic dispatch yet, but I kinda ran into challenges with that which is why this has slowed down a bit right now.

mitsuhiko avatar Apr 06 '22 10:04 mitsuhiko