rust-sysfs-gpio icon indicating copy to clipboard operation
rust-sysfs-gpio copied to clipboard

Make operations on pins take mutable reference

Open Kixunil opened this issue 8 years ago • 1 comments

I believe it'd be more logical to take mutable reference to pins. I know that memory itself doesn't change, however, there are good reasons to require mutability anyway:

  • Accessing the pin from multiple threads probably isn't what people want to do by accident. (They still can do it on purpose.)
  • Requiring mutable reference allows people to write mocks and simulate the pins in tests.
  • It's more natural to use mutable references when you change something.
  • It clearly shows that some state is being mutated.

What do you think?

Kixunil avatar Dec 12 '16 18:12 Kixunil

How would your try and impliment this into the code?

SaberYoun6 avatar Jul 01 '17 00:07 SaberYoun6