Warning
This post was published 48 days ago. The information described in this article may have changed.
Assume I have a handler trait, a very complicated trait, and a function whose input implements the trait. The return type is also very complicated.
pub trait Handler<T> {
fn handle(&mut self, input: T);
}
pub trait VeryComplicated {
/* a lot of functions */
}
pub fn show(t: &mut impl VeryComplicated) -> impl Iterator<Item = i64>{
// do something
}
and then I have a generic function, that wants to handle the return type
fn do_something<T1: VeryComplicated, T2: /* how to bound it? */>(x: &mut T1, handler: &mut T2) {
let r = show(t1);
handler.handle(r);
}
The problem is how to bound the generic param T2
if it's impossible to get the returned type of process
. If I can bound T2
like "for every R: Iterator<Item = i64>, T2 implements Handler", the problem is solved.
2 posts - 2 participants
🏷️ rust_feed