2 releases

0.1.1 Jun 3, 2021
0.1.0 Jun 1, 2021

#503 in Rust patterns

Download history 8015/week @ 2023-12-14 6569/week @ 2023-12-21 6376/week @ 2023-12-28 7454/week @ 2024-01-04 7101/week @ 2024-01-11 7049/week @ 2024-01-18 7684/week @ 2024-01-25 11181/week @ 2024-02-01 11665/week @ 2024-02-08 10491/week @ 2024-02-15 9320/week @ 2024-02-22 10870/week @ 2024-02-29 11788/week @ 2024-03-07 15674/week @ 2024-03-14 13053/week @ 2024-03-21 8959/week @ 2024-03-28

51,329 downloads per month
Used in 77 crates (13 directly)

MPL-2.0 license

9KB
171 lines

indent

Crates.io Crates.io docs.rs Libraries.io dependency status for latest release Lines of code REUSE Compliance

This crate provides 4 functions useful for inserting a multiline string into an already indented context in another string:

  • indent_by: Indents every line that is not empty by the given number of spaces, starting from the second line.
  • indent_with: Indents every line that is not empty with the given prefix, starting from the second line.
  • indent_all_by: Indents every line that is not empty by the given number of spaces.
  • indent_all_with: Indents every line that is not empty with the given prefix.

Examples

fn main() {
    let string = "line one

line two
";
    assert_eq!("line one\n\n  line two\n", indent::indent_by(2, string));
}

License

Mozilla Public License 2.0

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be licensed under the Mozilla Public License 2.0, without any additional terms or conditions.

No runtime deps