You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example, in the following code all of the links will link to the rustdoc page for `Bar`:
52
46
53
47
```rust
54
-
/// Does the thing.
55
-
pubfndo_the_thing(_:SomeType) {
56
-
println!("Let's do the thing!");
57
-
}
48
+
/// This struct is not [Bar]
49
+
pubstructFoo1;
50
+
51
+
/// This struct is also not [bar](Bar)
52
+
pubstructFoo2;
53
+
54
+
/// This struct is also not [bar][b]
55
+
///
56
+
/// [b]: Bar
57
+
pubstructFoo3;
58
+
59
+
/// This struct is also not [`Bar`]
60
+
pubstructFoo4;
58
61
59
-
/// Token you use to [`do_the_thing`].
60
-
pubstructSomeType;
62
+
pubstructBar;
61
63
```
62
64
63
-
The link to ``[`do_the_thing`]`` in `SomeType`'s docs will properly link to the page for `fn
64
-
do_the_thing`. Note that here, rustdoc will insert the link target for you, but manually writing the
65
-
target out also works:
65
+
You can refer to anything in scope, and use paths, including `Self`. You may also use `foo()` and `foo!()` to refer to methods/functions and macros respectively.
66
66
67
-
```rust
68
-
pubmodsome_module {
69
-
/// Token you use to do the thing.
70
-
pubstructSomeStruct;
71
-
}
67
+
```rust,edition2018
68
+
use std::sync::mpsc::Receiver;
72
69
73
-
///Does the thing. Requires one [`SomeStruct`] for the thing to work.
70
+
/// This is an version of [`Receiver`], with support for [`std::future`].
74
71
///
75
-
/// [`SomeStruct`]: some_module::SomeStruct
76
-
pubfndo_the_thing(_:some_module::SomeStruct) {
77
-
println!("Let's do the thing!");
72
+
/// You can obtain a [`std::future::Future`] by calling [`Self::recv()`].
73
+
pub struct AsyncReceiver<T> {
74
+
sender: Receiver<T>
75
+
}
76
+
77
+
impl<T> AsyncReceiver<T> {
78
+
pub async fn recv() -> T {
79
+
unimplemented!()
80
+
}
78
81
}
79
82
```
80
83
81
-
For more details, check out [the RFC][RFC 1946], and see [the tracking issue][43466] for more
82
-
information about what parts of the feature are available.
84
+
Paths in Rust have three namespaces: type, value, and macro. Items from these namespaces are allowed to overlap. In case of ambiguity, rustdoc will warn about the ambiguity and ask you to disambiguate, which can be done by using a prefix like `struct@`, `enum@`, `type@`, `trait@`, `union@`, `const@`, `static@`, `value@`, `function@`, `mod@`, `fn@`, `module@`, `method@` , `macro@`, or `derive@`:
Note: Because of how `macro_rules` macros are scoped in Rust, the intra-doc links of a `macro_rules` macro will be resolved relative to the crate root, as opposed to the module it is defined in.
0 commit comments