From ee79b7bb4a3f16818a5ac488fbc95599f5453a2c Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Fri, 21 Aug 2020 14:18:06 +0300 Subject: [PATCH] Implement Clone trait for Options (#455) --- CHANGELOG.md | 1 + src/db_options.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c91e88..caec758 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] * Export the `DEFAULT_COLUMN_FAMILY_NAME` constant. +* Implement `Clone` trait for `Options`. ## 0.14.0 (2020-04-22) diff --git a/src/db_options.rs b/src/db_options.rs index 52a4141..73cdf08 100644 --- a/src/db_options.rs +++ b/src/db_options.rs @@ -328,6 +328,16 @@ impl Drop for Options { } } +impl Clone for Options { + fn clone(&self) -> Self { + let inner = unsafe { ffi::rocksdb_options_create_copy(self.inner) }; + if inner.is_null() { + panic!("Could not copy RocksDB options"); + } + Self { inner } + } +} + impl Drop for BlockBasedOptions { fn drop(&mut self) { unsafe {