- Notifications
You must be signed in to change notification settings - Fork 55
Open
Description
Hello! I'm trying to write a helper function that deserializes Value to T and returns a default value if deserialization fails. I noticed that if I replace sonic_rs with serde_json, it's works.
Here is a example code:
pub fn deserialize_skip_error<'de, T, D>(deserializer: D) -> Result<T, D::Error> where T: serde::Deserialize<'de> + Default, D: serde::Deserializer<'de>, { let value = sonic_rs::Value::deserialize(deserializer)?; let inner = T::deserialize(value).unwrap_or_default(); Ok(inner) }And error logs here:
the trait bound `sonic_rs::Value: extract_id::_::_serde::Deserializer<'_>` is not satisfied the trait `extract_id::_::_serde::Deserializer<'_>` is not implemented for `sonic_rs::Value` but it is implemented for `&sonic_rs::Value` for that trait implementation, expected `&sonic_rs::Value`, found `sonic_rs::Value` Windows 11
rustc 1.86.0-nightly (bef3c3b01 2025-02-04)
crates version:
sonic_rs: main branch
serde: 1.0.216
Metadata
Metadata
Assignees
Labels
No labels