#string #multiline #line-string #str #text #macro #join

multiline-str

A simple multiline string Rust macro, which allows you to write multiline strings in a more readable way. It allows for any combination of space-joined and newline-joined strings.

1 unstable release

0.1.1 Jun 4, 2024
0.1.0 Jun 4, 2024

#874 in Development tools

MIT license

5KB

Multiline str macro

Crates.io License Crates.io Version Crates.io Downloads

This is a simple multiline string Rust macro, which allows you to write multiline strings in a more readable way. It allows for any combination of space-joined and newline-joined strings.

Usage

use multiline_str::multiline_str;

let s = multiline_str! {
    "This is a line",
    "and this line joins the previous one, with a space",
    "and so does this one";
    "But this line is separated by a newline",
    "and this one joins the previous one, with a space";
    "";
    "This line is separated by two newlines"
};

println!("{}", s);

Output:

This is a line and this line joins the previous one, with a space and so does this one
But this line is separated by a newline and this one joins the previous one, with a space

This line is separated by two newlines

Contributing

If you have any suggestions, improvements or bug reports, feel free to open an issue or a pull request. I'm always happy to receive feedback and contributions!

License

This project is licensed under the MIT license. Refer to the LICENSE file for more information.

No runtime deps