Last active
September 12, 2022 10:40
-
-
Save nmrshll/55b4a4d03ef925a902d101f49b8a06e6 to your computer and use it in GitHub Desktop.
Rust recursive await
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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