-
Notifications
You must be signed in to change notification settings - Fork 37
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
Fix clippy warnings. #88
Conversation
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.
this looks like a great initial cleanup, thank you so much! only question was on the one transmute, but it looks fine to me. otherwise i think we have to merge your other PR and fix ci in it before we merge this one?
I fixed the CI - MSRV in #90 |
so if you're having trouble fixing this, you can do:
|
@m4b and @Frostie314159 I created a PR for this PR - fixing merge conflicts. It should be merged in before merging this PR - Frostie314159#1 |
Merge with main, fixing merge conflicts
@nyurik it still says there is a merge conflict? |
@m4b those fixes were also done and merged in by my earlier PR. This PR only has the stuff that my (also clippy-inspired PR) did not have. The diff tool (add Main branch has two commits: f5beda1 and 30f49c7. The second commit is mostly irrelevant (format inlining), so comparing with it is pointless because it will just increase the noise. The first commit on the other hand is the one that contains a lot of the changes that were also done by this commit. You can see it by comparing it with 62c5fcf: Now the very next commit - caf60bb:
Next is the merge commit -- eac19ef -- merge commit is a noop for us, so same results as before
So in short - all transmute fixes are already in the main branch. |
P.S. the conflict is tiny - I fixed it in Frostie314159#2 -- this is again just a simple PR that was created with -- this PR modifies two lines: this and this - both in |
Merge in the main branch and fixes last remaining conflicts
Thank you so much! |
bytes_to.iter_mut().enumerate().for_each(|(i, item)| { | ||
*item = bytes_from.pread(i).unwrap(); | ||
}); |
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 think this is a bit hard to read - iterating over the "target" as mutable. I would suggest a simpler variant (i didn't test it, might not even compile) -- iterate over source values, pushing them into the output array.
bytes_to.iter_mut().enumerate().for_each(|(i, item)| { | |
*item = bytes_from.pread(i).unwrap(); | |
}); | |
for (idx, value) in bytes_from.iter().enumerate() { | |
bytes_to[i] = value.unwrap(); | |
}); |
bytes_to[i] = bytes_from.gread(&mut offset).unwrap(); | ||
} | ||
let offset = &mut 0; | ||
bytes_to.iter_mut().for_each(|item| { |
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.
same as above
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.
although this might need to be different - not certain about this one
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.
This was the clippy suggestion.
@@ -136,6 +137,11 @@ impl<'a> Segments<'a> { | |||
Ok(sections) | |||
} | |||
} | |||
impl<'a> Default for Segments<'a> { |
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.
Why is this needed? You can simply add #[derive(Default)]
on the Segments
struct, and make new()
call Self::default()
. Also, I am not too certain if both default()
and new()
are needed. I think cleaner interface would be to have just one. This way if later you need new(some_init_value)
, it can be easily added.
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.
Good idea, I can get to this tomorrow.
18d11bc
to
d369188
Compare
i believe all these fixes have been merged, if not we should do this in another PR since this has conflicts, etc. |
This also removes multiple uses of transmute, which have safe equivalents. All tests pass and clippy is happy.