2 releases

0.1.1 Jun 3, 2021
0.1.0 Jun 1, 2021

#367 in Text processing

Download history 22043/week @ 2024-07-21 22642/week @ 2024-07-28 24415/week @ 2024-08-04 24392/week @ 2024-08-11 22503/week @ 2024-08-18 17322/week @ 2024-08-25 17363/week @ 2024-09-01 15610/week @ 2024-09-08 16316/week @ 2024-09-15 15698/week @ 2024-09-22 11386/week @ 2024-09-29 15719/week @ 2024-10-06 15604/week @ 2024-10-13 13040/week @ 2024-10-20 14175/week @ 2024-10-27 14185/week @ 2024-11-03

57,899 downloads per month
Used in 113 crates (22 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