Allow async-specific generic parameters and return type #23
+134
−56
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.
Changes
Allow
async_signatureto have:async_signature(...) -> ReturnTypeasync_signature<T: TraitA, U>(...) where U: TraitBIf omitted, the synchronous implementation’s generic parameters and return type are used.
Motivation
Sometimes when working with both sync and async implementations, there is a situation where the generic parameters of a function and/or the return value are not the same.
E.g. if we have traits:
it is currently not possible to write a function like:
Solution
This PR adds return types and generic parameters to the
async_signatureargument.The syntax is just like writing a function named
async_signature:If the generics or return type are omitted, those of the sync implementation are used. This means there is no breaking change in this PR, the behavior is the same as before, unless some generic parameters or a return type is specified.
Notes
syn::Parseinstead of manually parsing theTokenTree