Skip to content

Utilities for working with impl traits in Rust.

License

Notifications You must be signed in to change notification settings

mendess/impl-trait-utils

 
 

Repository files navigation

Latest Version Documentation GHA Status License

Utilities for working with impl traits 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 Sendable version of your trait, you'd write:

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

Which creates a new IntFactory: Send trait and additionally bounds IntFactory::make(): Send and IntFactory::stream(): Send. Implementers of the trait can choose to implement the variant instead of the original trait.

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

License and usage notes

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

About

Utilities for working with impl traits in Rust.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%