Uh oh!
There was an error while loading. Please reload this page.
spki: add AlgorithmIdentifierRef::to_owned method - #796
Closed
baloo wants to merge 2 commits into
Closed
Conversation
tarcieri
commented
Dec 14, 2022
Member
Perhaps we can define some traits for this, since we can't use It would be nice to ensure there's always a reciprocal operation ala |
baloo
commented
Dec 14, 2022
MemberAuthor
I'm pretty bad at naming things, but any opinion? pubtraitDerBorrow{typeBorrowed<'b>whereSelf:'b;fnder_borrow<'a>(&'aself) -> Self::Borrowed<'a>;}pubtraitDerToOwned<'a>{typeDerOwned:DerBorrow<Borrowed<'a> = Self>whereSelf:'a;fnto_der_owned(&self) -> Self::DerOwned;}impl<'a>DerToOwned<'a>forAlgorithmIdentifierRef<'a>{typeDerOwned = AlgorithmIdentifierOwned;fnto_der_owned(&self) -> Self::DerOwned{AlgorithmIdentifier{oid:self.oid,parameters:self.parameters.map(|p| p.into()),}}}implDerBorrowforAlgorithmIdentifierOwned{typeBorrowed<'a> = AlgorithmIdentifierRef<'a>;fnder_borrow<'a>(&'aself) -> AlgorithmIdentifierRef<'a>{AlgorithmIdentifier{oid:self.oid,parameters:self.parameters.as_ref().map(AnyRef::from),}}}Compiler seems happy. |
tarcieri
commented
Dec 14, 2022
Member
That looks okay naming aside. Let me think about that for a bit. |
tarcieri
commented
Dec 14, 2022
Member
Naming wise, for starters, the "borrowed" types are owned |
MemberAuthor
pubtraitOwnedToRef{typeBorrowed<'b>whereSelf:'b;fnto_ref<'a>(&'aself) -> Self::Borrowed<'a>;}pubtraitRefToOwned<'a>{typeOwned:OwnedToRef<Borrowed<'a> = Self>whereSelf:'a;fnto_owned(&self) -> Self::Owned;} |
tarcieri
commented
Dec 14, 2022
Member
Looking better… maybe |
tarcieri pushed a commit
that referenced
this pull request
Dec 17, 2022
This introduces the two new traits to go from a ref object to an owned object as discussed in #796
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 freeto 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.
No description provided.