Link within documentation within macro

Hello, I am working on a macro that generates new methods for some type. I also want these methods to have some documentation including links to other methods. A minimal example will be something like this.

pub struct Number {
    x: i32,

macro_rules! twice_func {
    ($func:ident) => {
        impl Number {
            /// Add one to the number.
            pub fn $func(&self) -> Self {
                Self { x: self.x + 1 }

            /// call the function [Number::$func] twice on the same input.
            pub fn twice_that(&self) -> Self {


However, when generating the doc, the [Number::$func] part is added literally.

Do you know how to generate a link in that case?

It's not beautiful, but it works.

#[doc = concat!(
            "call the function [`Number::",
            "`] twice on the same input."
pub fn twice_that(&self) -> Self {
1 Like

Great. Thank you :slight_smile:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.