logoalt Hacker News

Rendellotoday at 7:13 PM0 repliesview on HN

Aside: one Zig (syntax) feature that I really missed in Rust is shown in the second code block, namely prefixed multi-line string literals à la:

    const text =
        \\This is a long comment
        \\But I can split it among lines arbitrarily
        \\And keep my indentation.
    ;
I've started using the Rust macro library `docstr` [1], which does the same thing:

    const TEXT: &'static str = docstr!(
        /// Now I can do it in Rust, too.
        /// I prefer this style a lot of the time
        /// for long texts.
    );
It even works with macros (example from the docs):

    let greeting: String = docstr!(format!
        /// Hello, my name is {name}.
        /// I am {} years old!
        age
    );
1. https://docs.rs/docstr/latest/docstr/