`signals.fuse`: method not found
WhyNotHugo opened this issue ยท 3 comments
I'm using some code very very similar to the example one from the docs:
async fn handle_signals(signals: Signals) {
let mut signals = signals.fuse();
while let Some(signal) = signals.next().await {
match signal {
SIGALRM => {
println!("Got an alarm! ๐")
}
_ => unreachable!(),
}
}
}
However, it seems the method signal.fuse
does not exist:
error[E0599]: no method named `fuse` found for struct `signal_hook_tokio::SignalsInfo` in the current scope
--> src/main.rs:24:31
|
24 | let mut signals = signals.fuse();
| ^^^^ method not found in `signal_hook_tokio::SignalsInfo`
|
::: /home/hugo/.cache/cargo/registry/src/github.com-1ecc6299db9ec823/signal-hook-tokio-0.3.0/src/lib.rs:92:1
|
92 | pub struct SignalsInfo<E: Exfiltrator = SignalOnly>(OwningSignalIterator<UnixStream, E>);
| ----------------------------------------------------------------------------------------- doesn't satisfy `signal_hook_tokio::SignalsInfo: Iterator`
|
= note: the method `fuse` exists but the following trait bounds were not satisfied:
`signal_hook_tokio::SignalsInfo: Iterator`
which is required by `&mut signal_hook_tokio::SignalsInfo: Iterator`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0599`.
Is this a bug?
Fuse comes from the StreamExt
trait. I assume you're missing the import.
https://docs.rs/futures/0.3.13/futures/stream/trait.StreamExt.html#method.fuse
Alternatively, you may be missing the feature flag: https://github.com/vorner/signal-hook/blob/master/signal-hook-tokio/src/lib.rs#L147
Anyway, it's possible you don't really need fuse โ you'd need it if you intended to continue pulling items out of the stream even after he first None.
Ah, I was missing both the feature flag and the import.
That worked, thanks! I didn't realise that fuse
was part of the Stream
trait, that didn't seem obvious in context.