Merge pull request #36 from erickt/main Include license files in cargo package
Merge pull request #36 from erickt/main
Include license files in cargo package
Utilities for working with impl Traits in Rust.
impl Trait
trait_variant
trait_variant generates a specialized version of a base trait that uses async fn and/or -> impl Trait.
async fn
-> impl Trait
For example, if you want a Sendable version of your trait, you’d write:
Send
#[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:
trait_variant::make
IntFactory
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.
LocalIntFactory
For more details, see the docs for trait_variant::make.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
Utilities for working with
impl Traits in Rust.trait_varianttrait_variantgenerates a specialized version of a base trait that usesasync fnand/or-> impl Trait.For example, if you want a
Sendable version of your trait, you’d write:The
trait_variant::makewould generate an additional trait calledIntFactory:Implementers can choose to implement either
LocalIntFactoryorIntFactoryas appropriate.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.