-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: derive AsRef for CommitmentProofBytes #1008
Conversation
Derive AsRef for CommitmentProofBytes so it’s possible to access its underlying bytes without having to own it. The type can be converted into Vec but that requires ownership. If all one has is a reference to the proof bytes (as in verify_membership method for example), there’s no way to access underlying bytes without cloning it first. With derive_more::AsRef added, one can now use as_ref method to borrow the underlying byets slice. Whilo at it. Replace explicit From implementation by derive_more::Into and get rid of unnecessary clone inside of conversion into MerkleProof.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1008 +/- ##
==========================================
- Coverage 70.69% 70.69% -0.01%
==========================================
Files 178 178
Lines 17870 17868 -2
==========================================
- Hits 12634 12631 -3
- Misses 5236 5237 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mina86 for this improvement. 👌🏻
* feat: derive AsRef for CommitmentProofBytes Derive AsRef for CommitmentProofBytes so it’s possible to access its underlying bytes without having to own it. The type can be converted into Vec but that requires ownership. If all one has is a reference to the proof bytes (as in verify_membership method for example), there’s no way to access underlying bytes without cloning it first. With derive_more::AsRef added, one can now use as_ref method to borrow the underlying byets slice. Whilo at it. Replace explicit From implementation by derive_more::Into and get rid of unnecessary clone inside of conversion into MerkleProof. * log * nit: remove now redundant clones * chore: remove redundant conversion to MerkleProof from owned CommitmentProofBytes --------- Co-authored-by: Farhad Shabani <[email protected]>
Derive AsRef for CommitmentProofBytes so it’s possible to access its
underlying bytes without having to own it.
The type can be converted into Vec but that requires ownership. If
all one has is a reference to the proof bytes (as in verify_membership
method for example), there’s no way to access underlying bytes without
cloning it first.
With derive_more::AsRef added, one can now use as_ref method to borrow
the underlying bytes slice.
While at it. Replace explicit From implementation by derive_more::Into
and get rid of unnecessary clone inside of conversion into MerkleProof.
PR author checklist:
unclog
.docs/
).Reviewer checklist:
Files changed
in the GitHub PR explorer.