fix: Make the set_iterate_upper_bound ReadOptions method unsafe (#309)

master
Clément Renault 5 years ago committed by Ilya Bogdanov
parent 9e75179e77
commit c5e8c9f5ef
  1. 11
      src/db.rs

@ -1804,8 +1804,15 @@ impl ReadOptions {
} }
} }
/// Set the upper bound for an iterator, and the upper bound itself is not included on the iteration result. /// Set the upper bound for an iterator.
pub fn set_iterate_upper_bound<K: AsRef<[u8]>>(&mut self, key: K) { /// The upper bound itself is not included on the iteration result.
///
/// # Safety
///
/// This function will store a clone of key and will give a raw pointer of it to the
/// underlying C++ API, therefore, when given to any other [`DB`] method you must ensure
/// that this [`ReadOptions`] value does not leave the scope too early (e.g. `DB::iterator_cf_opt`).
pub unsafe fn set_iterate_upper_bound<K: AsRef<[u8]>>(&mut self, key: K) {
let key = key.as_ref(); let key = key.as_ref();
unsafe { unsafe {
ffi::rocksdb_readoptions_set_iterate_upper_bound( ffi::rocksdb_readoptions_set_iterate_upper_bound(

Loading…
Cancel
Save