futures-rs
futures-rs copied to clipboard
TryStream and compiler “limitations”
Reading
https://github.com/rust-lang/futures-rs/blob/3601bb76708ea4bcc14c3491237abc33b685ba0b/futures-core/src/stream.rs#L174-L182
I’m wondering: what’s those limitations?
Trying something like b7f417d738d89071fe4d2ec880a908d67e19c12c seems to work without problems.
IIRC limitation is: https://github.com/rust-lang/futures-rs/issues/1776#issuecomment-518307092
However, a recent compiler change (probably in 1.52) may have fixed this.
Okay; even on older versions it still seems to work by means of writing
pub trait TryStream: Stream<Item = Result<<Self as TryStream>::Ok, <Self as TryStream>::Error>> {
/// The type of successful values yielded by this future
type Ok;
/// The type of failures yielded by this future
type Error;
}
instead of
pub trait TryStream: Stream<Item = Result<Self::Ok, Self::Error>> {
/// The type of successful values yielded by this future
type Ok;
/// The type of failures yielded by this future
type Error;
}
but perhaps that workaround wasn’t known by the author of the comment.
Nevermind, even that more explicit version doesn’t work before 1.46
; the TryStream
trait may be older than that? Edit: Yes it is.
…and I see a MSRV of 1.41
for futures if I’m interpreting that correctly. At least the comment should be updated to reflect that current Rust versions don’t have the limitation anymore. What’s the MSRV policy here? At least in an eventual 0.4
release that supertrait bound should probably be introduced; and removing the method requires a new semver-major version anyways.
The current MSRV for futures
/futures-util
is 1.41, and for some crates, such as futures-core
, which provides only traits, the MSRV is 1.36.
The MSRV policy for futures
/futures-util
is basically "whatever popular distros support". (https://github.com/rust-lang/futures-rs/pull/2405)
In 0.4, the trait aliases will be moved to futures-util
(https://github.com/rust-lang/futures-rs/issues/2207#issue-693060183), so it is okay to change the MSRV of futures-util
0.4 to 1.46 and remove the try_poll_next
method.