Skip to main content

docstr

Macro docstr 

Source
docstr!() { /* proc-macro */ }
Expand description

Turns documentation comments into string at compile-time.

use docstr::docstr;

let hello_world: String = docstr!(format!
    /// fn say_hi() {{
    ///     println!("Hello, my name is {}");
    /// }}
    "Bob"
);

assert_eq!(hello_world, r#"fn say_hi() {
    println!("Hello, my name is Bob");
}"#);

Expands to this:

format!(r#"fn say_hi() {{
    println!("Hello, my name is {}");
}}"#, "Bob");

See the crate-level documentation for more info