Skip to content

Commit

Permalink
Improve unit_error documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo157 committed Apr 15, 2019
1 parent b4a78bc commit 32303d5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion futures-util/src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,8 @@ pub trait FutureExt: Future {
Box::pin(self)
}

/// Turns a `Future` into a `TryFuture` with `Error = ()`.
/// Turns a [`Future<Output = T>`](Future) into a
/// [`TryFuture<Ok = T, Error = ()`>](futures_core::future::TryFuture).
fn unit_error(self) -> UnitError<Self>
where Self: Sized
{
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/future/never_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl<Fut, T> Future for NeverError<Fut>
{
type Output = Result<T, !>;

fn poll(self: Pin<&mut Self>, cx: &task::Context<'_>) -> Poll<Result<T, !>> {
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Result<T, !>> {
self.future().poll(cx).map(Ok)
}
}
5 changes: 1 addition & 4 deletions futures-util/src/future/unit_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use futures_core::future::{FusedFuture, Future};
use futures_core::task::{Context, Poll};
use pin_utils::unsafe_pinned;

/// Future for the `unit_error` combinator, turning a `Future` into a `TryFuture`.
///
/// This is created by the `FutureExt::unit_error` method.
/// Future for the [`unit_error`](super::FutureExt::unit_error) combinator.
#[derive(Debug)]
#[must_use = "futures do nothing unless polled"]
pub struct UnitError<Fut> {
Expand All @@ -15,7 +13,6 @@ pub struct UnitError<Fut> {
impl<Fut> UnitError<Fut> {
unsafe_pinned!(future: Fut);

/// Creates a new UnitError.
pub(super) fn new(future: Fut) -> UnitError<Fut> {
UnitError { future }
}
Expand Down
2 changes: 1 addition & 1 deletion futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub mod future {
OptionFuture,

FutureExt,
FlattenStream, Flatten, Fuse, Inspect, IntoStream, Map, Then,
FlattenStream, Flatten, Fuse, Inspect, IntoStream, Map, Then, UnitError,
};

#[cfg(feature = "alloc")]
Expand Down

0 comments on commit 32303d5

Please sign in to comment.