Skip to content

Commit

Permalink
Expand example to show how to implement qualified trait names
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtriplett committed Aug 24, 2022
1 parent 3c8618f commit 589db1f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,23 @@ macro_rules! r#try {
/// }
/// ```
///
/// If you also need the trait names themselves, such as to implement one or both on your types,
/// import the containing module and then name them with a prefix:
///
/// ```
/// # #![allow(unused_imports)]
/// use std::fmt::{self, Write as _};
/// use std::io::{self, Write as _};
///
/// struct Example;
///
/// impl fmt::Write for Example {
/// fn write_str(&mut self, _s: &str) -> core::fmt::Result {
/// unimplemented!();
/// }
/// }
/// ```
///
/// Note: This macro can be used in `no_std` setups as well.
/// In a `no_std` setup you are responsible for the implementation details of the components.
///
Expand Down

0 comments on commit 589db1f

Please sign in to comment.