Crates.io | dedent |
lib.rs | dedent |
version | 0.1.1 |
source | src |
created_at | 2024-11-03 00:22:55.642631 |
updated_at | 2024-11-03 01:05:25.534218 |
description | Procedural macro for stripping indentation from multi-line string literals |
homepage | https://github.com/nyarthan/dedent |
repository | https://github.com/nyarthan/dedent |
max_upload_size | |
id | 1433283 |
size | 13,485 |
A Rust procedural macro for stripping whitespace from multi-line string literals while preserving relative indentation.
use dedent::dedent;
fn main() {
// Basic usage
let code = dedent!(r#"
fn main() {
println!("Hello, world!");
}
"#);
println!("{}", code);
// Output:
// fn main() {
// println!("Hello, world!");
// }
// Works with varying indentation
let text = dedent!(r#"
First line
Indented line
More indented
Back to start
"#);
println!("{}", text);
// Output:
// First line
// Indented line
// More indented
// Back to start
}
The dedent!
macro:
Licensed under:
This crate is inspired by the dedent
npm package.