Allow using `into_stream()` with non-`'static` items
Currently, the Receiver::into_stream() method is not usable if the type being sent through the channel is not 'static.
fn main() {
let data = String::from("hello");
let (tx, rx) = flume::unbounded();
tx.send(&data).unwrap();
let _stream = rx.into_stream();
}
Output:
error[E0597]: `data` does not live long enough
--> src/main.rs:4:13
|
4 | tx.send(&data).unwrap();
| ^^^^^ borrowed value does not live long enough
5 | let _stream = rx.into_stream();
| ---------------- argument requires that `data` is borrowed for `'static`
6 | }
| - `data` dropped here while still borrowed
This is the current function signature for into_stream():
fn into_stream(self) -> RecvStream<'static, T>
If we change it to this...
fn into_stream<'a>(self) -> RecvStream<'a, T>
...the above code compiles.
I ran into this issue when switching from futures-channel, as the channels from that crate do not have this limitation.
I think that change should work. We can also change the lifetime param on into_send_async and other functions to 'a.
Sounds good to me. Any chance you could open a PR?
Added a PR for this. Let me know what else I need to do
Ideal, thanks! I believe this can be closed now.