callback-trait

Crates.iocallback-trait
lib.rscallback-trait
version0.1.3
sourcesrc
created_at2024-03-12 07:02:35.300816
updated_at2024-05-08 06:54:26.818186
descriptionImplement trait for Fn so that functions that accept traits as parameters can directly receive Fn parameters.
homepage
repositoryhttps://github.com/wugren/callback-trait.git
max_upload_size
id1170258
size53,806
(wugren)

documentation

README

callback-trait

Implement trait for Fn so that functions that accept traits as parameters can directly receive Fn parameters, such as:

#[callback_trait]
pub trait ExampleCallback {
	async fn call(&self, p1: u32, p2, u32) -> Result<u32, u32>;
}

fn set_callback(callback: impl ExampleCallback) {
    
}

set_callback(|p1: u32, p2: u32| {
    async move {
        Ok(0)
    }
})

Commit count: 6

cargo fmt