This repository was archived by the owner on Jun 25, 2025. It is now read-only.
Repository navigation
v0.0.4 async-trait
Support async traits
Correctly, it was fixed to properly handle lifetime bounds generated by async-trait.
By the way, v0.0.3 was published by mistake.
Example Heres:
#![feature(async_fn_in_trait)]
use async_trait::async_trait;
use auto_delegate::{Delegate, delegate};
#[async_trait]
#[delegate]
pub trait Calc {
async fn calc(&self, x1: usize, x2: usize) -> usize;
}
#[derive(Default)]
pub struct Child;
#[async_trait]
impl Calc for Child {
async fn calc(&self, x1: usize, x2: usize) -> usize {
x1 + x2
}
}
#[derive(Delegate, Default)]
#[to(Calc)]
pub struct Parent(Child);
#[tokio::main]
async fn main() {
let mut parent = Parent::default();
println!("{}", parent.calc(3, 2).await)
}