Skip to content

Commit c19d43f

Browse files
authored
Misc docs fixes (#2067)
1 parent c8f3919 commit c19d43f

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

futures-channel/src/mpsc/mod.rs

+8-8
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

+1-1
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

+1-1
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/stream/stream/mod.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,12 @@ pub trait StreamExt: Stream {
544544
Flatten::new(self)
545545
}
546546

547-
/// Combinator similar to [`StreamExt::fold`] that holds internal state and produces a new stream.
547+
/// Combinator similar to [`StreamExt::fold`] that holds internal state
548+
/// and produces a new stream.
548549
///
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.
550+
/// Accepts initial state and closure which will be applied to each element
551+
/// of the stream until provided closure returns `None`. Once `None` is
552+
/// returned, stream will be terminated.
551553
///
552554
/// # Examples
553555
///
@@ -580,7 +582,7 @@ pub trait StreamExt: Stream {
580582
///
581583
/// This function, like `Iterator::skip_while`, will skip elements on the
582584
/// stream until the predicate `f` resolves to `false`. Once one element
583-
/// returns false all future elements will be returned from the underlying
585+
/// returns `false`, all future elements will be returned from the underlying
584586
/// stream.
585587
///
586588
/// # Examples
@@ -611,7 +613,7 @@ pub trait StreamExt: Stream {
611613
///
612614
/// This function, like `Iterator::take_while`, will take elements from the
613615
/// stream until the predicate `f` resolves to `false`. Once one element
614-
/// returns false it will always return that the stream is done.
616+
/// returns `false`, it will always return that the stream is done.
615617
///
616618
/// # Examples
617619
///
@@ -1117,7 +1119,7 @@ pub trait StreamExt: Stream {
11171119
Forward::new(self, sink)
11181120
}
11191121

1120-
/// Splits this `Stream + Sink` object into separate `Stream` and `Sink`
1122+
/// Splits this `Stream + Sink` object into separate `Sink` and `Stream`
11211123
/// objects.
11221124
///
11231125
/// This can be useful when you want to split ownership between tasks, or

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,9 @@ 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.
390391
///
391392
/// # Examples
392393
///

futures/tests/stream.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ fn scan() {
2020
futures::executor::block_on(async {
2121
assert_eq!(
2222
stream::iter(vec![1u8, 2, 3, 4, 6, 8, 2])
23-
.scan(1, |acc, e| {
24-
*acc += 1;
25-
futures::future::ready(if e < *acc { Some(e) } else { None })
23+
.scan(1, |state, e| {
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)