]> git.lizzy.rs Git - rust.git/blob - src/doc/unstable-book/src/language-features/doc-cfg.md
Omit 'missing IndexMut impl' suggestion when IndexMut is implemented.
[rust.git] / src / doc / unstable-book / src / language-features / doc-cfg.md
1 # `doc_cfg`
2
3 The tracking issue for this feature is: [#43781]
4
5 ------
6
7 The `doc_cfg` feature allows an API be documented as only available in some specific platforms.
8 This attribute has two effects:
9
10 1. In the annotated item's documentation, there will be a message saying "This is supported on
11     (platform) only".
12
13 2. The item's doc-tests will only run on the specific platform.
14
15 This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the
16 standard library be documented.
17
18 ```rust
19 #![feature(doc_cfg)]
20
21 #[cfg(any(windows, feature = "documentation"))]
22 #[doc(cfg(windows))]
23 /// The application's icon in the notification area (a.k.a. system tray).
24 ///
25 /// # Examples
26 ///
27 /// ```no_run
28 /// extern crate my_awesome_ui_library;
29 /// use my_awesome_ui_library::current_app;
30 /// use my_awesome_ui_library::windows::notification;
31 ///
32 /// let icon = current_app().get::<notification::Icon>();
33 /// icon.show();
34 /// icon.show_message("Hello");
35 /// ```
36 pub struct Icon {
37     // ...
38 }
39 ```
40
41 [#43781]: https://github.com/rust-lang/rust/issues/43781
42 [#43348]: https://github.com/rust-lang/rust/issues/43348