cozo icon indicating copy to clipboard operation
cozo copied to clipboard

borrowed data escapes outside of method

Open RainerStorm opened this issue 2 years ago • 3 comments

After upgrade to Rust 1.74.0 I found that this function call in lib.rs (ln. 509) of cozo-core gave the error mentioned: thread::spawn(move || db.run_multi_transaction(write, app2db_recv, db2app_send)); "self escapes the method body here" I am experimenting with Arc<Mutex.. , but since I am new to Rust I wouldn't trust my solution if I found it.

RainerStorm avatar Nov 29 '23 02:11 RainerStorm

Can you give more details about your environment? I tried to compile cozodb with 1.74.0 and encountered no problems.

zh217 avatar Nov 29 '23 05:11 zh217

Working on Debian Bullseye. I separated cozo-core and cozorocks, in order to create elixir bindings. The solution I have now is to create a scope: // let db = self.clone(); <- seems to be redundant now thread::scope(|scope| { scope.spawn(move || self.run_multi_transaction(write, app2db_recv, db2app_send)); }); It compiles, but I don't know if there are other effects of this solution.

RainerStorm avatar Nov 29 '23 10:11 RainerStorm

The only differences in Cargo.toml are upgrades to serde, but I hardly believe these cause the problem. Looking at the solution, maybe something was hidden there. serde = { version = "1.0.193" } serde_json = "1.0.81" serde_derive = "1.0.192" serde_bytes = "0.11.7"

By the way: thank you for this project, it's very inspiring.

RainerStorm avatar Nov 30 '23 08:11 RainerStorm