macros: add "local" runtime flavor (#7375)

This commit is contained in:
James Kay
2025-07-28 13:59:00 +02:00
committed by GitHub
parent ce41896f8d
commit 4b96af6040
4 changed files with 130 additions and 21 deletions
+11 -1
View File
@@ -16,6 +16,13 @@ async fn spawning() -> usize {
join.await.unwrap()
}
#[cfg(tokio_unstable)]
#[tokio::main(flavor = "local")]
async fn local_main() -> usize {
let join = tokio::task::spawn_local(async { 1 });
join.await.unwrap()
}
#[test]
fn main_with_spawn() {
assert_eq!(1, spawning());
@@ -24,5 +31,8 @@ fn main_with_spawn() {
#[test]
fn shell() {
assert_eq!(1, basic_main());
assert_eq!(bool::default(), generic_fun::<bool>())
assert_eq!(bool::default(), generic_fun::<bool>());
#[cfg(tokio_unstable)]
assert_eq!(1, local_main());
}