serde
serde copied to clipboard
Add lifetime container attribute for user-provided lifetime
This PR is for discussion and related to #2190. As discussed there, the benefit is not obvious (except for providing more control to the user).
With this PR, a user can use #[serde(lifetime = 'a)]
to control the lifetime of the implementation of Deserialize
. In particular, the user is now able to control all the implementation parameters when using #[serde(bound = "", lifetime = 'a)]
.
See https://github.com/ia0/wasefire/blob/ccf7bc30ac8440b30981b2f39b734de10d1a037c/crates/protocol/src/lib.rs#L65 for an example in real code which gives impl<'a, T: Direction<'a>> _serde::Deserialize<'a> for Api<'a, T>
when looking with cargo expand
. The preceding commented line is the solution without this PR.