Skip to content

Commit 12705b4

Browse files
authored
Rollup merge of #91192 - r00ster91:futuredocs, r=GuillaumeGomez
Some improvements to the async docs The goal here is to make the docs overall a little bit more comprehensive and add more links between the things. One thing that's not working yet is the links to the keywords. Somehow I couldn't get them to work. r? ````@GuillaumeGomez```` do you know how I could get the keyword links to work?
2 parents 1103d2e + 297364e commit 12705b4

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

library/core/src/future/future.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::ops;
55
use crate::pin::Pin;
66
use crate::task::{Context, Poll};
77

8-
/// A future represents an asynchronous computation.
8+
/// A future represents an asynchronous computation obtained by use of [`async`].
99
///
1010
/// A future is a value that might not have finished computing yet. This kind of
1111
/// "asynchronous value" makes it possible for a thread to continue doing useful
@@ -23,6 +23,7 @@ use crate::task::{Context, Poll};
2323
/// When using a future, you generally won't call `poll` directly, but instead
2424
/// `.await` the value.
2525
///
26+
/// [`async`]: ../../std/keyword.async.html
2627
/// [`Waker`]: crate::task::Waker
2728
#[doc(notable_trait)]
2829
#[must_use = "futures do nothing unless you `.await` or poll them"]

library/core/src/future/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#![stable(feature = "futures_api", since = "1.36.0")]
22

3-
//! Asynchronous values.
3+
//! Asynchronous basic functionality.
4+
//!
5+
//! Please see the fundamental [`async`] and [`await`] keywords and the [async book]
6+
//! for more information on asynchronous programming in Rust.
7+
//!
8+
//! [`async`]: ../../std/keyword.async.html
9+
//! [`await`]: ../../std/keyword.await.html
10+
//! [async book]: https://rust-lang.github.io/async-book/
411
512
use crate::{
613
ops::{Generator, GeneratorState},

library/std/src/keyword_docs.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -2203,37 +2203,39 @@ mod where_keyword {}
22032203
///
22042204
/// Use `async` in front of `fn`, `closure`, or a `block` to turn the marked code into a `Future`.
22052205
/// As such the code will not be run immediately, but will only be evaluated when the returned
2206-
/// future is `.await`ed.
2206+
/// future is [`.await`]ed.
22072207
///
2208-
/// We have written an [async book] detailing async/await and trade-offs compared to using threads.
2208+
/// We have written an [async book] detailing `async`/`await` and trade-offs compared to using threads.
22092209
///
22102210
/// ## Editions
22112211
///
22122212
/// `async` is a keyword from the 2018 edition onwards.
22132213
///
2214-
/// It is available for use in stable rust from version 1.39 onwards.
2214+
/// It is available for use in stable Rust from version 1.39 onwards.
22152215
///
22162216
/// [`Future`]: future::Future
2217+
/// [`.await`]: ../std/keyword.await.html
22172218
/// [async book]: https://rust-lang.github.io/async-book/
22182219
mod async_keyword {}
22192220

22202221
#[doc(keyword = "await")]
22212222
//
22222223
/// Suspend execution until the result of a [`Future`] is ready.
22232224
///
2224-
/// `.await`ing a future will suspend the current function's execution until the `executor`
2225+
/// `.await`ing a future will suspend the current function's execution until the executor
22252226
/// has run the future to completion.
22262227
///
2227-
/// Read the [async book] for details on how async/await and executors work.
2228+
/// Read the [async book] for details on how [`async`]/`await` and executors work.
22282229
///
22292230
/// ## Editions
22302231
///
22312232
/// `await` is a keyword from the 2018 edition onwards.
22322233
///
2233-
/// It is available for use in stable rust from version 1.39 onwards.
2234+
/// It is available for use in stable Rust from version 1.39 onwards.
22342235
///
22352236
/// [`Future`]: future::Future
22362237
/// [async book]: https://rust-lang.github.io/async-book/
2238+
/// [`async`]: ../std/keyword.async.html
22372239
mod await_keyword {}
22382240

22392241
#[doc(keyword = "dyn")]

0 commit comments

Comments
 (0)