nolife
nolife copied to clipboard
Draft: Add Send and Sync
Fixes #18
OK got it to work with:
diff --git a/README.md b/README.md
index 0c5a543..8213420 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,7 @@ impl<'a> nolife::Family<'a> for MyParsedDataFamily {
// 2. Define a function that setups the data and its borrowed representation:
fn my_scope(
data_source: Vec<u8>, // 👈 all parameters that allow to build a `MyData`
-) -> impl nolife::TopScope<Family = MyParsedDataFamily> // 👈 use the helper type we declared
+) -> impl nolife::TopScope<Family = MyParsedDataFamily, Future: core::future::Future + Send + Sync> // 👈 use the helper type we declared
{
nolife::scope!({
let mut data = MyData(data_source);
Unfortunately:
- Associated type bounds are only stabilized in 1.79, which is currently beta, so this code doesn't compile on stable yet
- I'm really not sure I like forcing the user to write this code. The error is a bit mysterious when the bound is missing, fixing it requires a good understanding of the behaviour of
impl Traitregarding the additional bounds on the types associated with the trait.
Not sure if there's another workaround.
diff --git a/README.md b/README.md
index 0c5a543..f01e4be 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,7 @@ impl<'a> nolife::Family<'a> for MyParsedDataFamily {
// 2. Define a function that setups the data and its borrowed representation:
fn my_scope(
data_source: Vec<u8>, // 👈 all parameters that allow to build a `MyData`
-) -> impl nolife::TopScope<Family = MyParsedDataFamily> // 👈 use the helper type we declared
+) -> impl nolife::TopScope<Family = MyParsedDataFamily, Future = impl Send + Sync> // 👈 use the helper type we declared
{
nolife::scope!({
let mut data = MyData(data_source);
Thanks, yandros :heart: