Skip to content

Instantly share code, notes, and snippets.

@andreastt
Created July 17, 2019 11:44
Show Gist options
  • Save andreastt/80e78ded11aefb03f8a6a7720a8d7f7d to your computer and use it in GitHub Desktop.
Save andreastt/80e78ded11aefb03f8a6a7720a8d7f7d to your computer and use it in GitHub Desktop.
fn from_value<'de, D, T>(deserializer: D) -> Result<T, D::Error>
where
D: Deserializer<'de>,
T: serde::de::DeserializeOwned,
{
#[derive(Debug, Deserialize)]
struct Wrapper<T> {
value: T,
}
let val = Wrapper::deserialize(deserializer)
.map_err(de::Error::custom)?;
Ok(val.value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment