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

Misc docs fixes #2067

Merged
merged 4 commits into from Feb 13, 2020
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
16 changes: 8 additions & 8 deletions futures-channel/src/mpsc/mod.rs
Expand Up @@ -109,7 +109,7 @@ struct BoundedSenderInner<T> {
// unblocked.
sender_task: Arc<Mutex<SenderTask>>,

// True if the sender might be blocked. This is an optimization to avoid
// `true` if the sender might be blocked. This is an optimization to avoid
// having to lock the mutex most of the time.
maybe_parked: bool,
}
Expand Down Expand Up @@ -189,15 +189,15 @@ impl fmt::Display for SendError {
impl std::error::Error for SendError {}

impl SendError {
/// Returns true if this error is a result of the channel being full.
/// Returns `true` if this error is a result of the channel being full.
pub fn is_full(&self) -> bool {
match self.kind {
SendErrorKind::Full => true,
_ => false,
}
}

/// Returns true if this error is a result of the receiver being dropped.
/// Returns `true` if this error is a result of the receiver being dropped.
pub fn is_disconnected(&self) -> bool {
match self.kind {
SendErrorKind::Disconnected => true,
Expand Down Expand Up @@ -227,12 +227,12 @@ impl<T> fmt::Display for TrySendError<T> {
impl<T: core::any::Any> std::error::Error for TrySendError<T> {}

impl<T> TrySendError<T> {
/// Returns true if this error is a result of the channel being full.
/// Returns `true` if this error is a result of the channel being full.
pub fn is_full(&self) -> bool {
self.err.is_full()
}

/// Returns true if this error is a result of the receiver being dropped.
/// Returns `true` if this error is a result of the receiver being dropped.
pub fn is_disconnected(&self) -> bool {
self.err.is_disconnected()
}
Expand Down Expand Up @@ -536,7 +536,7 @@ impl<T> BoundedSenderInner<T> {
// This operation will also atomically determine if the sender task
// should be parked.
//
// None is returned in the case that the channel has been closed by the
// `None` is returned in the case that the channel has been closed by the
// receiver. This happens when `Receiver::close` is called or the
// receiver is dropped.
let park_self = match self.inc_num_messages() {
Expand Down Expand Up @@ -997,7 +997,7 @@ impl<T> Receiver<T> {
/// no longer empty.
///
/// This function will panic if called after `try_next` or `poll_next` has
/// returned None.
/// returned `None`.
pub fn try_next(&mut self) -> Result<Option<T>, TryRecvError> {
match self.next_message() {
Poll::Ready(msg) => {
Expand Down Expand Up @@ -1127,7 +1127,7 @@ impl<T> UnboundedReceiver<T> {
/// no longer empty.
///
/// This function will panic if called after `try_next` or `poll_next` has
/// returned None.
/// returned `None`.
pub fn try_next(&mut self) -> Result<Option<T>, TryRecvError> {
match self.next_message() {
Poll::Ready(msg) => {
Expand Down
2 changes: 1 addition & 1 deletion futures-channel/src/oneshot.rs
Expand Up @@ -126,7 +126,7 @@ impl<T> Inner<T> {
}

// Note that this lock acquisition may fail if the receiver
// is closed and sets the `complete` flag to true, whereupon
// is closed and sets the `complete` flag to `true`, whereupon
// the receiver may call `poll()`.
if let Some(mut slot) = self.data.try_lock() {
assert!(slot.is_none());
Expand Down
2 changes: 1 addition & 1 deletion futures-executor/src/unpark_mutex.rs
Expand Up @@ -108,7 +108,7 @@ impl<D> UnparkMutex<D> {
self.status.store(POLLING, SeqCst);
}

/// Alert the mutex that polling completed with NotReady.
/// Alert the mutex that polling completed with `Pending`.
///
/// # Safety
///
Expand Down
14 changes: 8 additions & 6 deletions futures-util/src/stream/stream/mod.rs
Expand Up @@ -544,10 +544,12 @@ pub trait StreamExt: Stream {
Flatten::new(self)
}

/// Combinator similar to [`StreamExt::fold`] that holds internal state and produces a new stream.
/// Combinator similar to [`StreamExt::fold`] that holds internal state
/// and produces a new stream.
///
/// Accepts initial state and closure which will be applied to each element of the stream until provided closure
/// returns `None`. Once `None` is returned, stream will be terminated.
/// Accepts initial state and closure which will be applied to each element
/// of the stream until provided closure returns `None`. Once `None` is
/// returned, stream will be terminated.
///
/// # Examples
///
Expand Down Expand Up @@ -580,7 +582,7 @@ pub trait StreamExt: Stream {
///
/// This function, like `Iterator::skip_while`, will skip elements on the
/// stream until the predicate `f` resolves to `false`. Once one element
/// returns false all future elements will be returned from the underlying
/// returns `false`, all future elements will be returned from the underlying
/// stream.
///
/// # Examples
Expand Down Expand Up @@ -611,7 +613,7 @@ pub trait StreamExt: Stream {
///
/// This function, like `Iterator::take_while`, will take elements from the
/// stream until the predicate `f` resolves to `false`. Once one element
/// returns false it will always return that the stream is done.
/// returns `false`, it will always return that the stream is done.
///
/// # Examples
///
Expand Down Expand Up @@ -1117,7 +1119,7 @@ pub trait StreamExt: Stream {
Forward::new(self, sink)
}

/// Splits this `Stream + Sink` object into separate `Stream` and `Sink`
/// Splits this `Stream + Sink` object into separate `Sink` and `Stream`
/// objects.
///
/// This can be useful when you want to split ownership between tasks, or
Expand Down
5 changes: 3 additions & 2 deletions futures-util/src/stream/try_stream/mod.rs
Expand Up @@ -385,8 +385,9 @@ pub trait TryStreamExt: TryStream {
/// Skip elements on this stream while the provided asynchronous predicate
/// resolves to `true`.
///
/// This function is similar to [`StreamExt::skip_while`](crate::stream::StreamExt::skip_while)
/// but exits early if an error occurs.
/// This function is similar to
/// [`StreamExt::skip_while`](crate::stream::StreamExt::skip_while) but exits
/// early if an error occurs.
///
/// # Examples
///
Expand Down
6 changes: 3 additions & 3 deletions futures/tests/stream.rs
Expand Up @@ -20,9 +20,9 @@ fn scan() {
futures::executor::block_on(async {
assert_eq!(
stream::iter(vec![1u8, 2, 3, 4, 6, 8, 2])
.scan(1, |acc, e| {
*acc += 1;
futures::future::ready(if e < *acc { Some(e) } else { None })
.scan(1, |state, e| {
*state += 1;
futures::future::ready(if e < *state { Some(e) } else { None })
})
.collect::<Vec<_>>()
.await,
Expand Down