Skip to content

Instantly share code, notes, and snippets.

@nmrshll
Last active September 12, 2022 10:40
Show Gist options
  • Save nmrshll/55b4a4d03ef925a902d101f49b8a06e6 to your computer and use it in GitHub Desktop.
Save nmrshll/55b4a4d03ef925a902d101f49b8a06e6 to your computer and use it in GitHub Desktop.
Rust recursive await
let recursive_got = {
fn try_get() -> BoxFuture<'static, String> {
async move {
if something() {
return "hello".to_string();
}
tokio::time::sleep(Duration::from_millis(500)).await;
try_get(driver).await
}
.boxed()
}
try_get(driver).await
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment