Sha256: 3a657c1e24f3e0d51a0ef8bfee68f8a6a3c81727db0d782aba43a88f3978b082

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

[![Latest Version]][crates.io] [![Documentation]][docs.rs] [![GHA Status]][GitHub Actions] ![License]

Utilities for working with `impl Trait`s in Rust.

## `trait_variant`

`trait_variant` generates a specialized version of a base trait that uses `async fn` and/or `-> impl Trait`.

For example, if you want a [`Send`][rust-std-send]able version of your trait, you'd write:

```rust
#[trait_variant::make(IntFactory: Send)]
trait LocalIntFactory {
    async fn make(&self) -> i32;
    fn stream(&self) -> impl Iterator<Item = i32>;
    fn call(&self) -> u32;
}
```

The `trait_variant::make` would generate an additional trait called `IntFactory`:

```rust
use core::future::Future;

trait IntFactory: Send {
   fn make(&self) -> impl Future<Output = i32> + Send;
   fn stream(&self) -> impl Iterator<Item = i32> + Send;
   fn call(&self) -> u32;
}
```

Implementers can choose to implement either `LocalIntFactory` or `IntFactory` as appropriate.

For more details, see the docs for [`trait_variant::make`].

[`trait_variant::make`]: https://docs.rs/trait-variant/latest/trait_variant/attr.make.html

#### License and usage notes

Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or
[MIT license](LICENSE-MIT) at your option.

[GitHub Actions]: https://github.com/rust-lang/impl-trait-utils/actions
[GHA Status]: https://github.com/rust-lang/impl-trait-utils/actions/workflows/rust.yml/badge.svg
[crates.io]: https://crates.io/crates/trait-variant
[Latest Version]: https://img.shields.io/crates/v/trait-variant.svg
[Documentation]: https://img.shields.io/docsrs/trait-variant
[docs.rs]: https://docs.rs/trait-variant
[License]: https://img.shields.io/crates/l/trait-variant.svg
[rust-std-send]: https://doc.rust-lang.org/std/marker/trait.Send.html

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/trait-variant-0.1.2/README.md