Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format_static! #3021

Open
SoniEx2 opened this issue Nov 17, 2020 · 2 comments
Open

format_static! #3021

SoniEx2 opened this issue Nov 17, 2020 · 2 comments

Comments

@SoniEx2
Copy link

SoniEx2 commented Nov 17, 2020

Between rust-lang/rust#78837 and rust-lang/rust#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.

@mqudsi
Copy link

mqudsi commented Jan 1, 2021

Does it even need to have a different name? I imagine that in a const attribute context format!(...) to be what you call format_static!(...) and not the std::fmt format!?

@SoniEx2
Copy link
Author

SoniEx2 commented Jan 2, 2021

maybe format_const! then? (it'd also work in const contexts and stuff)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants