An open API service indexing awesome lists of open source software.

https://github.com/jharrilim/dedent-macro-rs

Proc macro for dedenting string literals
https://github.com/jharrilim/dedent-macro-rs

dedent macro rust strings

Last synced: 5 months ago
JSON representation

Proc macro for dedenting string literals

Awesome Lists containing this project

README

          

# dedent-macro

This crate provides a simple compile-time macro to dedent strings.
Useful for keeping consistent indentation within code.

Before:

```rust
fn write_win_status(x: bool) {
let s = if x {
"
Congratulations!
You won!
"
} else {
"
Uh oh,
try again!
"
}
println!("{s}");
}
```

after:

```rust
fn write_win_status(x: bool) {
let s = if x {
dedent!("
Congratulations!
You won!
")
} else {
dedent!("
Uh oh,
try again!
")
}
println!("{s}");
}

let s =
assert_eq!(s, "foo\nbar");
```