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.
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
Finite Data Structures #15
base: main
Are you sure you want to change the base?
Finite Data Structures #15
Changes from all commits
16b2364
51030a5
2ea5720
7931807
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
insert
usually returns the value that used to be in the map atk
. What's the design rational behind returning a copy? Also, when returning the object itself, it should consumeself
. Similarly forremove
.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.
If I understand your comment correctly, these functions ideally should mutate the struct rather than return a copy, however the design is as such due to the limitations in the ensures macro
Thus if this function were to return just the replaced value while being immutable, it is equivalent to
get
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.
keys
andvalues
functions usually return an iterator. You could also use a slice if iterators are too complex. What is the design rational behind using a vector here?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.
iterators are indeed complex, having to add lifetime variables to the trait and impl, seems like another battle with the borrowchecker.
I've also tried to look into slices, the issue is that the struct is a single vec of pairs, returning slices would require changing the struct to two parallel vecs one for keys another for values.
In light of this, should we change the struct? Or is Vec as a return type justified?
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.
Similar comments to the map. What's the design rational for these functions, esp. in deviating from the common behaviour in Rust?
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.
if its about not mutating the struct, again its due to the ensures macro