str-block 0.1.2

Remove the initial newline and common indentation from string literals
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 2 items with examples
  • Size
  • Source code size: 18.95 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 256.29 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • maia-s/proclet
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • maia-s

str-block

str_block is a proc macro for processing string literals. It removes the first line from its input if it's empty except for whitespace, and removes common indentation from the rest of the lines. Lines that are empty except for whitespace are treated as if they have the common indentation.

# use str_block::str_block;
assert_eq!(str_block! {"
    Hello
    World
"}, "Hello\nWorld\n");

Use with {} to stop rustfmt from moving around your string.

You can pass multiple string literals to str_block, and it'll concatenate them for you before processing the result. You can also pass raw string literals.