ownership issue
#7435
Replies: 1 comment 2 replies
-
The Option doesn't actually matter here, it fails before that already. In your command you accept an immutable instance of |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I think that's more a problem related to rust than tauri specifically but I failed to reproduce it without tauri so I will try asking here first:
I am trying to implement a managed state to share the client once it is initialized, I reduced the code to be more readable but the
client
method would create the client if client containsNone
and then return it.My issue is there in my commands:
If I call
client3
it works fine, no compiler error but if I useclient2
I get this error:Despite reading again and again everything I can find in the rust book and on the net about how ownership works I cannot understand the error and how to solve it.
As far as I understand the
Client
is owned by the Option which is owned by my state struct but when I clone it to return it the ownership of that new object moves to thewatch_pods
function and those assumptions seems correct but all hell break loose when I unwrap the Option.When using
client3
with an immutable reference it works but not withclient2
using a mutable reference and that's where I am lost, I don't see what link the clone Option toself
and how the type of reference I had on it when calling clone matters.Any help is welcome, I have been stuck on this for two days now and really want to understand.
Beta Was this translation helpful? Give feedback.
All reactions