rust-lang / rust-lang/impl-trait-utils
Support for inner types
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 134
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
This macro fails when you have inner types as context bounds of your trait functions.
Consider you have this type:
#[trait_variant::make(Aggregate: Send)]
pub trait LocalAggregate: Default + Serialize + DeserializeOwned + Sync + Send + Stream {
type Command: Send + Sync;
type Error: std::error::Error + From<AggregateStoreError>;
type Services: Send + Sync;
fn handle(
&self,
command: &Self::Command,
services: &Self::Services,
) -> impl Future<Output = Result<Vec<Self::Event>, Self::Error>>;
}
And you want to implement a trait where you can handle this aggregate commands like this:
#[trait_variant::make(AggregateStore: Send)]
pub trait LocalAggregateStore {
fn apply_command_and_store_events<A: Aggregate,>(
&self,
stream_id: &Urn,
stream_type: String,
metadata: crate::Metadata,
command: A::Command,
expected_version: Option<i64>,
) -> impl Future<Output = Result<(), A::Error>>
}
This fails to compile with next error:
--> es/src/persistence/store.rs:32:9
|
32 | command: A::Command,
| ^^^^^^^ cannot infer type
|
= note: cannot satisfy `<_ as Aggregate>::Command == _`
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
Start by reproducing the reported compilation failure at es/src/persistence/store.rs:32, then inspect how the #[trait_variant::make] macro handles the Aggregate and AggregateStore trait definitions. Done means the inner associated type used in the context-bound function compiles without the type-inference error and the generated trait remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100