vhbit / lmdb-rs

Rust bindings for LMDB
MIT License
114 stars 46 forks source link

Use "&mut self" in methods writing to Database #51

Closed radupopescu closed 7 years ago

radupopescu commented 7 years ago

This patch only modifies the methods modifying Database object, making them take &mut self as a parameter. This prevents the situation described in #48, where it's possible to have both a read-only reference and a writable reference to the same element.

I've fixed the compilation of the tests - it can be seen that the API changes introduced here are minimal.

The following functions were modified:

  1. Database::set
  2. Database::append
  3. Database::append_duplicate
  4. Database::insert
  5. Database::del
  6. Database::del_item
  7. Database::clear

Anyway, thanks for making the crate. It's really useful!

radupopescu commented 7 years ago

I made a mistake.

These changes are not enough to prevent the problem described. I'm closing this while I think about it.