poee

Crates.iopoee
lib.rspoee
version0.1.0
sourcesrc
created_at2023-05-29 15:27:12.098216
updated_at2023-05-29 15:27:12.098216
descriptionFunctions for efficient development
homepage
repositoryhttps://gitlab.com/andrew_ryan/poee
max_upload_size
id877196
size6,079
zinso (zinso)

documentation

https://docs.rs/poee

README

Macros for efficient development

Crates.io Rust license

Examples

Spawns a new asynchronous task, returning a JoinHandle for it.

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    poee::spawn(||{
        std::fs::write("demo0", "rust").unwrap();
    });
    fn demo(){
        std::fs::write("demo1", "rust").unwrap();
    }
    poee::spawn(demo);

    Ok(())
 }

Runs the provided closure on a thread where blocking is acceptable.

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
   poee::spawn_blocking(||{
       std::fs::write("demo0", "rust").unwrap();
   });
   fn demo(){
       std::fs::write("demo1", "rust").unwrap();
   }
   poee::spawn_blocking(demo);

   Ok(())
}    

executed on the async code in sync

fn main(){
   async fn demo(){
       println!("demo");
   }
   poee::sync_fn(demo());
}
Commit count: 0

cargo fmt