Crates.io | str-block |
lib.rs | str-block |
version | 0.1.2 |
source | src |
created_at | 2024-02-16 22:19:44.734567 |
updated_at | 2024-03-21 16:01:21.010504 |
description | Remove the initial newline and common indentation from string literals |
homepage | |
repository | https://github.com/maia-s/proclet |
max_upload_size | |
id | 1142837 |
size | 18,599 |
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.