spawn works as not expected
NightBlaze opened this issue · comments
Describe the bug
Still new to Rust so it's look like a bug in a wrapper of spawn
.
In general Rust code I can write:
#[tokio::main]
async fn main() {
let string = String::from("");
tokio::spawn(async move {
println!("{}", string);
tokio::spawn(async move {
println!("{}", string);
});
});
}
and it works as expected.
If I tried to write similar code in frb:
pub async fn foo() {
let string = String::from("");
flutter_rust_bridge::spawn(async move {
// println!("{}", string); // Even if this line is commented
flutter_rust_bridge::spawn(async move {
println!("{}", string);
});
});
}
then I have an error use of moved value: "string"
which is seems weird because I just move string
to the second spawn
's closure.
Steps to reproduce
pub async fn foo() {
let string = String::from("");
flutter_rust_bridge::spawn(async move {
// println!("{}", string); // Even if this line is commented
flutter_rust_bridge::spawn(async move {
println!("{}", string);
});
});
}
Logs
-
Expected behavior
No response
Generated binding code
No response
OS
No response
Version of flutter_rust_bridge_codegen
was 2.0.0-dev.24, updated to 2.0.0-dev.28 but idk did I it correct or not
Flutter info
No response
Version of clang++
No response
Additional context
No response
Hmm interesting. frb's spawn
fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
self.0.spawn(future)
}
calls tokio's spawn:
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
...
}
A quick look does not reveal any differences... Indeed if there is any difference, we cannot write down self.0.spawn
at all
Thus, could you please paste full error logs etc?
Found an issue. It's on my side. Sorry.
It's OK!