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
Regs access #149
base: master
Are you sure you want to change the base?
Regs access #149
Changes from 4 commits
1c0f624
ab67cd2
a05ecfd
bbe6a71
7790735
35e1523
fcc91e6
377b7e4
13f1fd2
29e13a0
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.
I don't like forcing allocations here by returning
Vec
. You can keep an allocation version for convenience, but please also create aregs_access_buf()
where the user can provide their own buffers (which may just be stack allocated).For simplicity, the
regs_access()
can callregs_access_buf()
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.
Should I just append the registers to the provided buffers, or should i clear them first?
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 the user may provide stack allocated buffers, doesn't that mean they generally have to provide the length aswell? If they can pass a
regs_read: &mut [u16; MAX_NUM_REGISTERS]
, how will we specify how many were actually read?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.
Instead of using a tuple, please make a new struct that makes it clear what is the read and write fields:
The return type would be
CsResult<RegAccess>
.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.
I used that struct but made the fields public, is it good now?
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.
use an early return in the case of an error to reduce the indentation of the "happy" case
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.
are you referring to the entire outer
if cfg!(...) {
? I agree it's cleaner, however the entire file is written this way currently :)