From f4665cbb0ac4adb28971efe800a346eba0f98341 Mon Sep 17 00:00:00 2001
From: Georgy Moshkin <gmoshkin@picodata.io>
Date: Fri, 21 Apr 2023 18:57:54 +0300
Subject: [PATCH] refactor: OpResult::result no longer takes self by value

It's too restrictive and is only useful in a single case of
PersistInstance, which is going to be replaced with OpDml anyway.
---
 src/traft/op.rs | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/traft/op.rs b/src/traft/op.rs
index 0c41baa0ad..2cc353f093 100644
--- a/src/traft/op.rs
+++ b/src/traft/op.rs
@@ -16,7 +16,7 @@ pub trait OpResult {
     // FIXME: this signature makes it look like result of any operation depends
     // only on what is contained within the operation which is almost never true
     // And it makes it hard to do anything useful inside this function.
-    fn result(self) -> Self::Result;
+    fn result(&self) -> Self::Result;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -147,7 +147,7 @@ impl std::fmt::Display for Op {
 
 impl OpResult for Op {
     type Result = ();
-    fn result(self) -> Self::Result {}
+    fn result(&self) -> Self::Result {}
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -165,8 +165,8 @@ impl PersistInstance {
 
 impl OpResult for PersistInstance {
     type Result = Box<Instance>;
-    fn result(self) -> Self::Result {
-        self.0
+    fn result(&self) -> Self::Result {
+        self.0.clone()
     }
 }
 
@@ -223,12 +223,12 @@ pub enum Dml {
 
 impl OpResult for Dml {
     type Result = tarantool::Result<Option<Tuple>>;
-    fn result(self) -> Self::Result {
+    fn result(&self) -> Self::Result {
         match self {
-            Self::Insert { space, tuple } => space.insert(&tuple).map(Some),
-            Self::Replace { space, tuple } => space.replace(&tuple).map(Some),
-            Self::Update { space, key, ops } => space.primary_index().update(&key, &ops),
-            Self::Delete { space, key } => space.primary_index().delete(&key),
+            Self::Insert { space, tuple } => space.insert(tuple).map(Some),
+            Self::Replace { space, tuple } => space.replace(tuple).map(Some),
+            Self::Update { space, key, ops } => space.primary_index().update(key, ops),
+            Self::Delete { space, key } => space.primary_index().delete(key),
         }
     }
 }
-- 
GitLab