From c5e8c9f5ef4bf8b85877b4dbb8c7c83f51e04c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Sat, 7 Sep 2019 15:04:08 +0200 Subject: [PATCH] fix: Make the set_iterate_upper_bound ReadOptions method unsafe (#309) --- src/db.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/db.rs b/src/db.rs index 9af7e72..2fd59c5 100644 --- a/src/db.rs +++ b/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. - pub fn set_iterate_upper_bound>(&mut self, key: K) { + /// Set the upper bound for an iterator. + /// 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>(&mut self, key: K) { let key = key.as_ref(); unsafe { ffi::rocksdb_readoptions_set_iterate_upper_bound(