str-block

Crates.iostr-block
lib.rsstr-block
version0.1.2
sourcesrc
created_at2024-02-16 22:19:44.734567
updated_at2024-03-21 16:01:21.010504
descriptionRemove the initial newline and common indentation from string literals
homepage
repositoryhttps://github.com/maia-s/proclet
max_upload_size
id1142837
size18,599
Maia (maia-s)

documentation

https://docs.rs/str-block

README

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.

Commit count: 226

cargo fmt