-
Notifications
You must be signed in to change notification settings - Fork 249
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
Implement Debug
for collection types
#647
Merged
Merged
Conversation
This file contains 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
itegulov
requested review from
austinabell,
ChaoticTempest,
evgenykuzyakov and
mikedotexe
as code owners
November 29, 2021 07:05
itegulov
force-pushed
the
debug-for-collections
branch
from
November 29, 2021 07:32
4b845fc
to
eee73c0
Compare
austinabell
suggested changes
Nov 29, 2021
itegulov
force-pushed
the
debug-for-collections
branch
from
November 30, 2021 01:56
eee73c0
to
6a95c13
Compare
itegulov
force-pushed
the
debug-for-collections
branch
from
November 30, 2021 02:00
6a95c13
to
b42230d
Compare
@austinabell I have addressed your comments, should be better now. PTAL whenever you can. |
itegulov
force-pushed
the
debug-for-collections
branch
from
November 30, 2021 02:16
b42230d
to
21b45c8
Compare
austinabell
approved these changes
Dec 10, 2021
itegulov
force-pushed
the
debug-for-collections
branch
from
December 10, 2021 05:35
bbfd3d0
to
955cbae
Compare
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.
Closes #564
This PR implements
Debug
trait in a uniform fashion forUnorderedMap
,UnorderedSet
,LookupMap
,LookupSet
,TreeMap
,LegacyTreeMap
andLazyOption
.Where possible I tried to provide a human-readable list of elements as if it was just a plain Rust collection, but for some of them (
LookupMap
andLookupSet
) it is impossible to do by design, so I think the best we can do is to show the known internal stuff. Implementations forTreeMap
andLegacyTreeMap
were actually already present, I just had to move them outside of test scope. I made one compromise in tests: in order not to complicate the test logic too much, most of them assume that the values/pairs are going to be displayed in the order of their insertion.Also, this is just a side thought, but while implementing the traits I noticed that we could split the implementations for
UnorderedSet
,UnorderedMap
and others into two separate set of functions whenK
andV
are eitherBorshSerialize
orBorshDeserialize
(the way it is done in Vector: see [1], [2]).