I have a piece of code as follows:
fn stream_it(&self) -> Box<dyn Stream<Item=()>> {
Box::new(self.some_field)
}
fn consume_it(&self) {
let a = self.stream_it().map(|i| i);
}
And I am getting the compilation error:
error: the `map` method cannot be invoked on a trait object
--> ...
|
69 | let a = self.stream_it().map(|i| i);
| ^^^
|
::: ...
|
257 | Self: Sized,
| ----- this has a `Sized` requirement
|
= note: other candidates were found in the following traits, perhaps add a `use` for one_of_them:
candidate #1: `use futures_util::future::future::FutureExt;`
candidate #2: `use futures_signals::signal::signal::SignalExt;`
candidate #3: `use futures_util::stream::stream::StreamExt;`
candidate #4: `use futures_signals::signal_vec::SignalVecExt;`
candidate #5: `use async_std::stream::stream::StreamExt;`
I understand that the Sized
requirement is necessary, but I don't know how to fulfill it. Is it even possible to map over a Stream of unit?