Closed SpriteOvO closed 11 months ago
It is not built in because that particular trait is never what I have needed in my own uses of deserializing with erased-serde.
FWIW, this is my use case:
pub struct Registry {
components: HashMap<String, Box<dyn ErasedDeserializeOwned>>,
}
impl Registry {
pub fn register(
&mut self,
name: impl Into<String>,
value: impl serde::de::DeserializeOwned,
) -> Result<()> {
self.components.insert(name.into(), Box::new(value));
Ok(())
}
}
If I open a PR for adding it into the crate, would you mind merging it?
I would not merge it. I think I would need to see evidence of an equivalent trait being broadly used in many crates that use erased-serde's Deserializer.
The code you wrote in https://github.com/dtolnay/erased-serde/issues/33#issuecomment-605387719 is very generic, why not include it in this crate? So that users no longer copy this code to each of their own crates, and
erased-serde
can also provide traits that are consistent withserde
.