Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

borrowed data escapes outside of method #208

Open
RainerStorm opened this issue Nov 29, 2023 · 3 comments
Open

borrowed data escapes outside of method #208

RainerStorm opened this issue Nov 29, 2023 · 3 comments

Comments

@RainerStorm
Copy link

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.

@zh217
Copy link
Contributor

zh217 commented Nov 29, 2023

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

@RainerStorm
Copy link
Author

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants