Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ban manual implementation of TryFuture and TryStream #1777

Merged
merged 1 commit into from Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion futures-core/src/future/mod.rs
Expand Up @@ -47,9 +47,17 @@ where
}
}

mod private_try_future {
use super::Future;

pub trait Sealed {}

impl<F, T, E> Sealed for F where F: ?Sized + Future<Output = Result<T, E>> {}
}

/// A convenience for futures that return `Result` values that includes
/// a variety of adapters tailored to such futures.
pub trait TryFuture {
pub trait TryFuture: private_try_future::Sealed {
/// The type of successful values yielded by this future
type Ok;

Expand Down
10 changes: 9 additions & 1 deletion futures-core/src/stream.rs
Expand Up @@ -112,9 +112,17 @@ where
}
}

mod private_try_stream {
use super::Stream;

pub trait Sealed {}

impl<S, T, E> Sealed for S where S: ?Sized + Stream<Item = Result<T, E>> {}
}

/// A convenience for streams that return `Result` values that includes
/// a variety of adapters tailored to such futures.
pub trait TryStream {
pub trait TryStream: private_try_stream::Sealed {
/// The type of successful values yielded by this future
type Ok;

Expand Down