Implement cast from lifetime-free to unbound types#24
Open
zheland wants to merge 2 commits intosagebind:masterfrom
Open
Implement cast from lifetime-free to unbound types#24zheland wants to merge 2 commits intosagebind:masterfrom
zheland wants to merge 2 commits intosagebind:masterfrom
Conversation
7b75e1e to
67d6d16
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The
TryCast{Mut,Ref,Owned}LifetimeFreetraits are implemented forLifetimeFreetarget types, but not implemented forLifetimeFreesource types.This PR adds
TryCast{Mut,Ref,Owned}LifetimeFreeBacktraits with source types bounded byLifetimeFreetrait.This makes it possible to upcast types and make specialized builders/decoders/constructors like this:
This PR is based on (includes) another PR #23 and might require rebase before merging if needed. This PR includes additional tests for both PRs. You can use last commit (7b75e1e if not changed) for better diffs related to this PR changes only.
Common implementations for
*LifetimeFree::try_castand*LifetimeFreeBack::try_castmethods are extracted into separate private functions to reduce boilerplate code.New autoderef ordering:
TryCastMutLifetimeFree,TryCastMutLifetimeFreeBack(new),TryCastRefLifetimeFree,TryCastRefLifetimeFreeBack(new),TryCastOwnedLifetimeFree,TryCastOwnedLifetimeFreeBack(new),TryCastSliceMut,TryCastSliceRef,TryCastMut,TryCastRef,TryCastOwned