#macro #proc-macro #place #wish #less #readable #non-proc

place_macro

Macros you wish you had while you were writing your non-proc macro

5 releases (1 stable)

1.0.0 Dec 22, 2023
0.2.0 Sep 22, 2023
0.1.3 Sep 3, 2023

#245 in Procedural macros

Download history 9/week @ 2024-07-28 14/week @ 2024-08-04 8/week @ 2024-08-11 7/week @ 2024-08-18 22/week @ 2024-08-25 32/week @ 2024-09-01 28/week @ 2024-09-08 15/week @ 2024-09-15 72/week @ 2024-09-22 53/week @ 2024-09-29 78/week @ 2024-10-06 31/week @ 2024-10-13 56/week @ 2024-10-20 127/week @ 2024-10-27 37/week @ 2024-11-03 35/week @ 2024-11-10

255 downloads per month
Used in 6 crates (via termal_core)

Custom license

19KB

Place-macro

crates.io Downloads

Macros you wish you had while you were writing your non-proc macro.

This library privides some macros that make writing regural non-proc macros much simpler, readable and with less dirty tricks.

The main macro of this library is place. It is able to expand the macros in this library in reverse expansion order.

If you have some macros that you would like to add feel free to open new issue on GitHub.

How to get it

With cargo

cargo add place_macro

In Cargo.toml

[dependencies]
place_macro = "1.0.0"

Macros

  • place: expands the following macros in reverse order, see docs for more info
  • ignore: expands to nothing
  • identity: expands to what is given, it bypasses the reverse order in the place macro
  • dollar: expands to dollar sign $
  • string: concats the contents into single string, see the doc
  • identifier: concats the contents into sintle identifier in the same way as string
  • head: expands to the first token
  • tail: expands to all but the first token
  • start: expands to all but the last token
  • last: expands to the last token
  • reverse: expands to the tokens in reverse order
  • stringify: expands to string of the input
  • replace_newline: replaces all newlines and folowing whitespace in literal with the given literal
  • str_replace: replace in string literal
  • to_case: change the case of a identifier

Examples

For examples and more detailed info about how to use the macros in this crate see docs

Dependencies

~680KB
~10K SLoC