You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The save and load methods on the storage traits take exclusive ownership of the data passed to them. I propose that instead of taking ownership, we instead borrow the values in these methods.
What do you think?
Problem
Currently, if you write something like this, you get a compiler error because the variable key is owned by the first function that it gets passed to, storage.save.
error[E0382]: use of moved value: `key`
--> src/cape/storage.rs:205:35
|
202 | let key = "my-object".to_string();
| --- move occurs because `key` has type `std::string::String`, which does not implement the `Copy` trait
203 | let storage = S3SyncStorage::default();
204 | storage.save(key, Value::from(expected));
| --- value moved here
205 | let loaded = storage.load(key);
| ^^^ value used here after move
FYI this is a larger pending issue in the current runtime, where we currently often move Values instead of borrowing. Makes sense to start optimizing this though so I'd say go for it!
Hi gang,
If we take a look at the following line: https://github.com/tf-encrypted/runtime/blob/7254b6230fdf0af1061e3848e419b2514a5875cc/rust/moose/src/storage.rs#L13
The save and load methods on the storage traits take exclusive ownership of the data passed to them. I propose that instead of taking ownership, we instead borrow the values in these methods.
What do you think?
Problem
Currently, if you write something like this, you get a compiler error because the variable
key
is owned by the first function that it gets passed to, storage.save.Compiler error message:
Solution
The text was updated successfully, but these errors were encountered: