serde-rs.github.io
serde-rs.github.io copied to clipboard
Add an example for arbitrary type validation upon deserialization.
This adds an example for a useful pattern where a type needs to be validated arbitrarily (via TryFrom
on an inner type) during deserialization. This comes directly from https://github.com/serde-rs/serde/issues/642#issuecomment-683276351 where I learned the pattern.
I couldn't figure out on my own how to do this via browsing https://serde.rs, so I went to the issue tracker where I found this recipe, so it seems like a good candidate for the examples section.
I think this is pretty useful, but it might be worth mentioning https://github.com/serde-rs/serde/issues/2178 as a limitation.