🦀 Abstract over Send and !Send traits https://crates.io/crates/future_form
  • Rust 95.3%
  • Nix 4.7%
Find a file
2026-01-25 16:27:05 -08:00
.forgejo Improve docs & tests 2026-01-14 13:43:37 -08:00
future_form Fix EXTENSIONS.md path for cargo publish 2026-01-25 16:27:05 -08:00
future_form_macros Fix macro: multiletter type params failed to parse 2026-01-25 16:08:47 -08:00
.gitignore Port basics over 2026-01-11 15:04:47 -08:00
Cargo.lock Rename to future_form and extensivelyrename/refactor (#2) 2026-01-25 15:42:50 -08:00
Cargo.toml Rename to future_form and extensivelyrename/refactor (#2) 2026-01-25 15:42:50 -08:00
DESIGN.md Rename to future_form and extensivelyrename/refactor (#2) 2026-01-25 15:42:50 -08:00
flake.lock Fix flake 2026-01-23 19:40:07 -08:00
flake.nix Rename to future_form and extensivelyrename/refactor (#2) 2026-01-25 15:42:50 -08:00
HACKING.md Rename to future_form and extensivelyrename/refactor (#2) 2026-01-25 15:42:50 -08:00
LICENSE-APACHE Rename to future_form and extensivelyrename/refactor (#2) 2026-01-25 15:42:50 -08:00
LICENSE-MIT Rename to future_form and extensivelyrename/refactor (#2) 2026-01-25 15:42:50 -08:00
README.md Rename to future_form and extensivelyrename/refactor (#2) 2026-01-25 15:42:50 -08:00

future_form

"This isn't even my final future form!"

Abstractions over Send and !Send futures in Rust.

The Problem

Async Rust has a fragmentation problem: some runtimes require Send futures (like tokio), while others work with !Send futures (like Wasm). This forces library authors to either duplicate their async trait implementations or exclude legitimate use cases.

The Solution

future_form lets you write async code once and support both Send and !Send futures:

use future_form::{FutureForm, Sendable, Local, future_form};
use std::marker::PhantomData;

trait Counter<K: FutureForm> {
    fn next(&self) -> K::Future<'_, u32>;
}

struct Memory<K> {
    val: u32,
    _marker: PhantomData<K>,
}

// Generates impl for both Sendable and Local
#[future_form(Sendable, Local)]
impl<K: FutureForm> Counter<K> for Memory<K> {
    fn next(&self) -> K::Future<'_, u32> {
        let val = self.val;
        K::from_future(async move { val + 1 })
    }
}

Packages

Crate Description
future_form Core traits and types (FutureForm, Sendable, Local)
future_form_macros The #[future_form] attribute macro

See the future_form README for full documentation, usage patterns, and comparisons with async-trait and trait-variant.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.