[go: up one dir, main page]

Today I Learned

tags


2022/12/10

That you can include doc-comments in macros:

macro_rules! documented {
    (
        $(#[$outer:meta])*
        $name:ident
    ) => {
        $(#[$outer])*
        fn $name(&self) {}
    };
}

documented!(
    /// documented
    my_function
);

my_function(); // hovering "function" now shows that the doc-comment is "documented"

h/t https://stackoverflow.com/a/33999625/6571327