Hi, I'm Eric.

I’m an avid world traveler, photographer, software developer, and digital storyteller.

I help implement the Content Authenticity Initiative at Adobe.

Search Results

Rust Trick for Repetitive Documentation

Found on 9 November 2023 via Mastodon 450

via Valentine Briese :transuwu:: Little bit of a trick I discovered for documenting fields which are on multiple structures:

macro_rules! extensions_doc {
    () => {
        r#"The extensions properties are implemented as patterned fields that are always prefixed by `"x-"`."#
    };
}

pub struct Info {
    // ...
    #[doc = extensions_doc!()]
    pub extensions: HashMap<String, Value>,
}

If you’ve enjoyed this …

Subscribe to my free and occasional (never more than weekly) e-mail newsletter with my latest travel and other stories:

Or follow me on one or more of the socials: