]> git.proxmox.com Git - rustc.git/blame - src/doc/unstable-book/src/language-features/doc-spotlight.md
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / doc / unstable-book / src / language-features / doc-spotlight.md
CommitLineData
3dfed10e
XL
1# `doc_spotlight`
2
3The tracking issue for this feature is: [#45040]
4
5The `doc_spotlight` feature allows the use of the `spotlight` parameter to the `#[doc]` attribute,
6to "spotlight" a specific trait on the return values of functions. Adding a `#[doc(spotlight)]`
7attribute to a trait definition will make rustdoc print extra information for functions which return
6a06907d
XL
8a type that implements that trait. For example, this attribute is applied to the `Iterator`,
9`io::Read`, `io::Write`, and `Future` traits in the standard library.
3dfed10e
XL
10
11You can do this on your own traits, like this:
12
13```
14#![feature(doc_spotlight)]
15
16#[doc(spotlight)]
17pub trait MyTrait {}
18
19pub struct MyStruct;
20impl MyTrait for MyStruct {}
21
22/// The docs for this function will have an extra line about `MyStruct` implementing `MyTrait`,
23/// without having to write that yourself!
24pub fn my_fn() -> MyStruct { MyStruct }
25```
26
27This feature was originally implemented in PR [#45039].
28
29[#45040]: https://github.com/rust-lang/rust/issues/45040
30[#45039]: https://github.com/rust-lang/rust/pull/45039