async_trait_proto 0.0.3

Async traits using nightly features
Documentation

async_trait_proto

Crates.io docs.rs Benchmark Rust

Async trait prototype using the desugarization described in RFC 3185 Static Async Fn in Traits.

It should be faster than async-trait because it doesn't use allocations on every invocation and type erasure.

Benchmark

Requires these feature flags and a nightly compiler:

  • #![feature(generic_associated_types)]
  • #![feature(type_alias_impl_trait)]

Example

#![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]
use async_trait_proto::async_trait_proto;
struct Foo;

#[async_trait_proto]
trait Bar {
    async fn wait(&self);
}

#[async_trait_proto]
impl Bar for Foo {
    async fn wait(&self) {
        sleep(Duration::from_secs(10)).await;
    }
}

License: Unlicense