mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-25 00:00:18 +02:00
26 lines
400 B
Rust
26 lines
400 B
Rust
#![cfg(feature = "macros")]
|
|||
|
|
|
||
|
|
#[tokio::main]
|
||
|
|
async fn basic_main() -> usize {
|
||
|
|
1
|
||
|
|
}
|
||
|
|
|
||
|
|
#[cfg(feature = "rt-core")]
|
||
|
|
mod spawn {
|
||
|
|
#[tokio::main]
|
||
|
|
async fn spawning() -> usize {
|
||
|
|
let join = tokio::spawn(async { 1 });
|
||
|
|
join.await.unwrap()
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn main_with_spawn() {
|
||
|
|
assert_eq!(1, spawning());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn shell() {
|
||
|
|
assert_eq!(1, basic_main());
|
||
|
|
}
|