I must explain to the compiler that
B
is the same asA::Foo
There is a special syntax for it:
impl<A, B> Baz<A, B>
where
A: Generator<Foo = B>,
{
fn add_foo(&mut self) {
self.vec.push(self.generator.generate());
}
}
More Related Contents:
- “Expected type parameter” error in the constructor of a generic struct
- How do I require a generic type implement an operation like Add, Sub, Mul, or Div in a generic function?
- How to write a trait bound for adding two references of a generic type?
- How do I use integer number literals when using generic types?
- How do I write the lifetimes for references in a type constraint when one of them is a local reference?
- How can I avoid a ripple effect from changing a concrete struct to generic?
- The trait cannot be made into an object
- Why does a generic method inside a trait require trait object to be sized?
- Conflicting implementations of trait in Rust
- How do I return a Filter iterator from a function?
- Why can’t I use a key function that returns a reference when sorting a vector with sort_by_key?
- Why can’t `&(?Sized + Trait)` be cast to `&dyn Trait`?
- Generics Error: expected type parameter, found struct
- Why can’t I add a blanket impl on a trait with a type parameter?
- Can I avoid eager ambiguity resolution for trait implementations with generics?
- What does the question mark mean in a type parameter bound?
- What does it mean to instantiate a Rust generic with an underscore?
- Writing a generic function that takes an iterable container as parameter in Rust
- How do I unwrap an arbitrary number of nested Option types?
- Unable to create a polymorphic type because the trait cannot be made into an object
- What is the cited problem with using generic type parameters in trait objects?
- Scala: Abstract types vs generics
- How does the reified keyword in Kotlin work?
- Scala 2.8 CanBuildFrom
- Generic higher order function
- How to use TypeToken + generics with Gson in Kotlin
- Difference between “*” and “Any” in Kotlin generics
- How to determine if a generic is an optional in Swift?
- Generic extending class AND implements interface in Kotlin
- Returning original collection type in generic method