Last active
March 26, 2018 19:39
-
-
Save MaikKlein/08d9359ac81ebbd04e09dac999ab1e05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub fn serde_from_str_opt<'de, D, T>(deserializer: D) -> Result<Option<T>, D::Error> | |
| where | |
| D: Deserializer<'de>, | |
| T: FromStr, | |
| T::Err: Display, | |
| { | |
| String::deserialize(deserializer) | |
| .map(|s| T::from_str(&s).ok()) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[serde(deserialize_with = "serde_from_str_opt")] | |
| pub average_price: Option<f32>, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment