Skip to content

Commit 477ba30

Browse files
committed
Misc docs fixes
1 parent 771513c commit 477ba30

File tree

7 files changed

+39
-24
lines changed

7 files changed

+39
-24
lines changed

futures-channel/src/mpsc/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct BoundedSenderInner<T> {
109109
// unblocked.
110110
sender_task: Arc<Mutex<SenderTask>>,
111111

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

191191
impl SendError {
192-
/// Returns true if this error is a result of the channel being full.
192+
/// Returns `true` if this error is a result of the channel being full.
193193
pub fn is_full(&self) -> bool {
194194
match self.kind {
195195
SendErrorKind::Full => true,
196196
_ => false,
197197
}
198198
}
199199

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

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

235-
/// Returns true if this error is a result of the receiver being dropped.
235+
/// Returns `true` if this error is a result of the receiver being dropped.
236236
pub fn is_disconnected(&self) -> bool {
237237
self.err.is_disconnected()
238238
}
@@ -536,7 +536,7 @@ impl<T> BoundedSenderInner<T> {
536536
// This operation will also atomically determine if the sender task
537537
// should be parked.
538538
//
539-
// None is returned in the case that the channel has been closed by the
539+
// `None` is returned in the case that the channel has been closed by the
540540
// receiver. This happens when `Receiver::close` is called or the
541541
// receiver is dropped.
542542
let park_self = match self.inc_num_messages() {
@@ -997,7 +997,7 @@ impl<T> Receiver<T> {
997997
/// no longer empty.
998998
///
999999
/// This function will panic if called after `try_next` or `poll_next` has
1000-
/// returned None.
1000+
/// returned `None`.
10011001
pub fn try_next(&mut self) -> Result<Option<T>, TryRecvError> {
10021002
match self.next_message() {
10031003
Poll::Ready(msg) => {
@@ -1127,7 +1127,7 @@ impl<T> UnboundedReceiver<T> {
11271127
/// no longer empty.
11281128
///
11291129
/// This function will panic if called after `try_next` or `poll_next` has
1130-
/// returned None.
1130+
/// returned `None`.
11311131
pub fn try_next(&mut self) -> Result<Option<T>, TryRecvError> {
11321132
match self.next_message() {
11331133
Poll::Ready(msg) => {

futures-channel/src/oneshot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<T> Inner<T> {
126126
}
127127

128128
// Note that this lock acquisition may fail if the receiver
129-
// is closed and sets the `complete` flag to true, whereupon
129+
// is closed and sets the `complete` flag to `true`, whereupon
130130
// the receiver may call `poll()`.
131131
if let Some(mut slot) = self.data.try_lock() {
132132
assert!(slot.is_none());

futures-executor/src/unpark_mutex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<D> UnparkMutex<D> {
108108
self.status.store(POLLING, SeqCst);
109109
}
110110

111-
/// Alert the mutex that polling completed with NotReady.
111+
/// Alert the mutex that polling completed with `Pending`.
112112
///
113113
/// # Safety
114114
///

futures-util/src/io/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ pub trait AsyncReadExt: AsyncRead {
312312
/// use futures::io::{self, AsyncReadExt, Cursor};
313313
///
314314
/// // Note that for `Cursor` the read and write halves share a single
315-
/// // seek position. This may or may not be true for other types that
315+
/// // seek position. This may or may not be `true` for other types that
316316
/// // implement both `AsyncRead` and `AsyncWrite`.
317317
///
318318
/// let reader = Cursor::new([1, 2, 3, 4]);

futures-util/src/stream/stream/mod.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,9 @@ pub trait StreamExt: Stream {
315315
///
316316
/// Note that this function consumes the stream passed into it and returns a
317317
/// wrapped version of it, similar to the existing `filter` methods in the
318-
/// standard library.
318+
/// standard library. Because of current HRTB limitations, reference to item
319+
/// can't be captured by the future. When it will be possible, method's signature
320+
/// may be changed.
319321
///
320322
/// # Examples
321323
///
@@ -544,10 +546,14 @@ pub trait StreamExt: Stream {
544546
Flatten::new(self)
545547
}
546548

547-
/// Combinator similar to [`StreamExt::fold`] that holds internal state and produces a new stream.
549+
/// Combinator similar to [`StreamExt::fold`] that holds internal state
550+
/// and produces a new stream.
548551
///
549-
/// Accepts initial state and closure which will be applied to each element of the stream until provided closure
550-
/// returns `None`. Once `None` is returned, stream will be terminated.
552+
/// Accepts initial state and closure which will be applied to each element
553+
/// of the stream until provided closure returns `None`. Once `None` is
554+
/// returned, stream will be terminated. Because of current HRTB limitations,
555+
/// `&mut` state can't be captured by the future. When it will be possible,
556+
/// method's signature may be changed.
551557
///
552558
/// # Examples
553559
///
@@ -580,8 +586,10 @@ pub trait StreamExt: Stream {
580586
///
581587
/// This function, like `Iterator::skip_while`, will skip elements on the
582588
/// stream until the predicate `f` resolves to `false`. Once one element
583-
/// returns false all future elements will be returned from the underlying
584-
/// stream.
589+
/// returns `false`, all future elements will be returned from the underlying
590+
/// stream. Because of current HRTB limitations, reference to item can't be
591+
/// captured by the future. When it will be possible, method's signature may
592+
/// be changed.
585593
///
586594
/// # Examples
587595
///
@@ -611,7 +619,9 @@ pub trait StreamExt: Stream {
611619
///
612620
/// This function, like `Iterator::take_while`, will take elements from the
613621
/// stream until the predicate `f` resolves to `false`. Once one element
614-
/// returns false it will always return that the stream is done.
622+
/// returns `false` it will always return that the stream is done. Because
623+
/// of current HRTB limitations, reference to item can't be captured by
624+
/// the future. When it will be possible, method's signature may be changed.
615625
///
616626
/// # Examples
617627
///
@@ -1117,7 +1127,7 @@ pub trait StreamExt: Stream {
11171127
Forward::new(self, sink)
11181128
}
11191129

1120-
/// Splits this `Stream + Sink` object into separate `Stream` and `Sink`
1130+
/// Splits this `Stream + Sink` object into separate `Sink` and `Stream`
11211131
/// objects.
11221132
///
11231133
/// This can be useful when you want to split ownership between tasks, or

futures-util/src/stream/try_stream/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,11 @@ pub trait TryStreamExt: TryStream {
385385
/// Skip elements on this stream while the provided asynchronous predicate
386386
/// resolves to `true`.
387387
///
388-
/// This function is similar to [`StreamExt::skip_while`](crate::stream::StreamExt::skip_while)
389-
/// but exits early if an error occurs.
388+
/// This function is similar to
389+
/// [`StreamExt::skip_while`](crate::stream::StreamExt::skip_while) but exits
390+
/// early if an error occurs. Because of current HRTB limitations, `Self::Ok`
391+
/// reference can't be captured by the future. When it will be possible,
392+
/// method's signature may be changed.
390393
///
391394
/// # Examples
392395
///
@@ -517,7 +520,9 @@ pub trait TryStreamExt: TryStream {
517520
///
518521
/// Note that this function consumes the stream passed into it and returns a
519522
/// wrapped version of it, similar to the existing `filter` methods in
520-
/// the standard library.
523+
/// the standard library. Because of current HRTB limitations, `Self::Ok`
524+
/// reference can't be captured by the future. When it will be possible,
525+
/// method's signature may be changed.
521526
///
522527
/// # Examples
523528
/// ```

futures/tests/stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ fn scan() {
2121
assert_eq!(
2222
stream::iter(vec![1u8, 2, 3, 4, 6, 8, 2])
2323
.scan(1, |acc, e| {
24-
*acc += 1;
25-
futures::future::ready(if e < *acc { Some(e) } else { None })
24+
*state += 1;
25+
futures::future::ready(if e < *state { Some(e) } else { None })
2626
})
2727
.collect::<Vec<_>>()
2828
.await,

0 commit comments

Comments
 (0)