Unfortunately I am not allowed to share my original code, but I think I was able to reproduce the exact same behavior in the Rust playground.
Given a struct with two members not implementing Copy, I’d like to call a method on the first member taking self and the second member as parameters (so basically “consuming” both).
This is working fine, as you can see from the example below.
In my original code I have to box the struct (I’m dealing with FFI) and as soon as I do that, the compiler shows a “use of moved value” error. Deref-ing the boxed value doesn’t work, too.
Since I am a new user and I can only attach two links to a post, all the above scenarios are here: https://play.rust-lang.org/?gist=ea632fd43e5fb34f0fe75b4742cc9617&version=nightly
If I move the logic inside a method of the struct taking self as parameter, the error disappears: https://play.rust-lang.org/?gist=18803599be821d699e57c867f2964aca&version=nightly
I have read that methods in Rust are nothing more than syntactic sugar on top of functions, but this doesn’t look like it.
I am not sure whether this is bug, a limitation of the compiler or just the lacking of my understanding of Rust nuances. Any insight would be much appreciated.