rust-lang / rust-lang/rfcs

format_static!

Open
#3,021 2 comments 22 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

Between https://github.com/rust-lang/rust/pull/78837 and https://github.com/rust-lang/rust/pull/79150, we feel like a format_static!() macro would be useful. This would allow one to, for example:

#[doc = format_static!(include!("docs_for_foo.md"), $arg1, $arg2)]

or even just for replacing these occurrences of concat! with something more human-readable: https://github.com/rust-lang/rust/pull/79150/files#diff-28f62e401cacbc5959e8762c79a4e0417d52ab64b2cd4e19cafa0d9f7e1bbaeeR30

such that

#[doc = concat!("For example, `Option<", stringify!($Ty), ">` is the same size as `", stringify!($Int), "`:")]

becomes

#[doc = format_static!("For example, `Option<{}>` is the same size as `{}`:", stringify!($Ty), stringify!($Int))]

which doesn't require whoever is maintaining the thing to parse the stringify!() parts before being able to continue.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read Rust PRs 78837 and 79150 first, especially the documented concat! and stringify! use cases. Determine the desired format_static! behavior and constraints from those examples; the work is complete when the macro's design and implementation requirements are specified clearly enough to evaluate or implement.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.