I want to initialize OnceCell with async function, but as #108, it seems difficult to support it right now.
To address this issue, I wrote a function like below:
async fn get_foo() -> Foo {
if let Some(foo) = Foo.get() {
return foo;
}
let foo = ...
Foo.get_or_init(|| foo) <- I want to execute this line without creating a closure
}
I want a method like set_and_get to avoid to use the closure in last line.
Related: #108
I want to initialize
OnceCell
with async function, but as #108, it seems difficult to support it right now. To address this issue, I wrote a function like below:I want a method like
set_and_get
to avoid to use the closure in last line.