Add lifetime container attribute for user-provided lifetime #2744
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofDeserialize
. 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 withcargo expand
. The preceding commented line is the solution without this PR.