Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

v0.0.4 async-trait

Choose a tag to compare

@not-elm not-elm released this 20 May 12:05
· 41 commits to master since this release

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)
}