rust-lang / rust-lang/impl-trait-utils
Allow creation of async variant for non-async triats
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 134
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
Not sure if this was considered when designing the crate, but I was hoping to have the following use case as handled by this crate as well
#[trait_variant::make(async_variant = [LocalAsyncSomeTrait, AsyncSomeTrait: Send])]
trait SomeTrait {
#[variant(make_async)]
fn blocking_method(&self) -> Result<Value, Error>;
#[variant(inherit)]
fn method_to_auto_impl(&self);
#[variant(skip)]
fn method_is_skipped(&self);
}
The above would expand to
trait LocalAsyncSomeTrait: SomeTrait {
fn blocking_method(&self) -> impl Future<Output = Result<Value, Error>>;
fn method_to_auto_impl(&self) {
<Self as SomeTrait>::method_to_auto_impl(self)
}
}
trait AsyncSomeTrait: LocalAsyncSomeTrait {
fn blocking_method(&self) -> impl Future<Output = Result<Value, Error>> + Send;
fn method_to_auto_impl(&self) {
<Self as SomeTrait>::method_to_auto_impl(self)
}
}
This way a single crate can defined multiple traits. This is in no way refined and probably needs some design, but would be great addition in my opinion
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named. Start by reviewing the existing trait_variant macro entry point and how it expands async variants, then compare that behavior with the proposed make_async, inherit, and skip attributes. Done means the design is settled and the requested local and Send async traits are generated consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100