-
Notifications
You must be signed in to change notification settings - Fork 294
Closed
Description
So this is something I'm hoping can be documented somewhere. I'm curious why the hashes derive copy because it seems like not the behavior you'd want. If you accidentally forget to pass your data by reference you will get an automatic copy which is not something you'd likely want in this case. Typically I've found if the impl
has mut
on self then you don't want copy.
e.g.
enum Foo {
Sha(sha2::Sha256),
Md5(md5::Md5),
}
struct Bar {
hash: Foo,
}
impl Bar {
fn some_data(&mut self, data: &[u8]) {
match self.hash {
Foo::Sha(mut hash) => hash.input(data),
Foo::Md5(mut hash) => hash.input(data),
}
}
}
What's the expected behavior here?
burdges
Metadata
Metadata
Assignees
Labels
No labels