fuze

Crates.iofuze
lib.rsfuze
version3.0.0
sourcesrc
created_at2021-07-15 15:01:03.184431
updated_at2021-07-22 10:29:50.865469
descriptionA mechanism to wait for a single signal which can be checked at any time
homepagehttps://github.com/passcod/superman/tree/main/fuze
repositoryhttps://github.com/passcod/superman/tree/main/fuze
max_upload_size
id423125
size9,094
Félix Saparelli (passcod)

documentation

https://docs.rs/fuze

README

Fuze

A mechanism to wait for a single signal which can be checked at any time.

A Fuze can be checked synchronously, and will show up as burnt only once it’s been burnt. It can be awaited while it’s unburnt, and it can be Cloned and used without mut at any time.

Useful for exit conditions and as a one-off no-payload channel.

use fuze::Fuze;
use async_std::task;
use std::time::Duration;

let f1 = Fuze::new();

let f2 = f1.clone();
task::block_on(async move {
   println!("Halo!");

  	task::spawn(async move {
  		task::sleep(Duration::from_secs(1)).await;
  		f3.burn();
  	});

  	f2.wait().await;
   println!("Adios!");
});
Commit count: 0

cargo fmt