heed
heed copied to clipboard
Replace the restrictive `&mut RwTxn` by less restrictive `&RwTxn`
The PR fixes #189 by removing all of the &mut RwTxn
requirements by simple &RwTxn
. If you want to understand the new possibilities I advise you to look at the example showcase non-mutable-rwtxn
.
Doing so allows very cool use cases like:
- being able to dump database entries into another one.
- write into a database with values from the same database.
- [ ] Should we also use a
&RwTxn
when creating databases?
let wtxn = env.write_txn()?;
for result in database1.iter(&wtxn)? {
let (k, v) = result?;
database2.put(&wtxn, k, v)?; // It now compiles and works perfectly 🎉
}