-
-
Notifications
You must be signed in to change notification settings - Fork 327
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
Remove MutVecInput and MappedInput in Favour of Impls on References #2783
Conversation
self.as_mut() | ||
} | ||
|
||
fn resize(&mut self, new_len: usize, value: u8) { |
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.
Doesn't this make using Vec
a bit of a headache whenever HasMutatorBytes
is in scope?
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, in the same file, one has HasMutatorBytes
in scope and uses any of the duplicate functions on a Vec<u8>
specifically, one would need to specify which implementation to use. Since one just forwards to the other, you can't really choose wrong, it's just annoying to write the extra code.
@@ -36,28 +36,28 @@ impl Input for CustomInput { | |||
|
|||
impl CustomInput { | |||
/// Returns a mutable reference to the byte array | |||
pub fn byte_array_mut(&mut self) -> MutVecInput<'_> { | |||
(&mut self.byte_array).into() | |||
pub fn byte_array_mut(&mut self) -> &mut Vec<u8> { |
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.
Nice!
Amazing, think we're almost there now! :) Much clener than before |
Careful, there's a difference between the mutators themselves ( Edit: Ah, wait. I misread. I don't really like those names tbh, I think they should at least have the word |
Sounds good. Anything shorter is good :) |
Turns out implementing the required traits directly on the borrows is possible and much cleaner.
This also allows removing
MappedInput
, which caused significant headaches for mapping mutators.