Crates.io | callback-trait |
lib.rs | callback-trait |
version | 0.1.3 |
source | src |
created_at | 2024-03-12 07:02:35.300816 |
updated_at | 2024-05-08 06:54:26.818186 |
description | Implement trait for Fn so that functions that accept traits as parameters can directly receive Fn parameters. |
homepage | |
repository | https://github.com/wugren/callback-trait.git |
max_upload_size | |
id | 1170258 |
size | 53,806 |
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)
}
})