indent

Crates.ioindent
lib.rsindent
version0.1.1
sourcesrc
created_at2021-06-01 00:01:22.334343
updated_at2021-06-03 01:49:07.537856
descriptionFunctions for indenting multiline strings
homepagehttps://todo.sr.ht/~ilkecan/indent-rs
repositoryhttps://git.sr.ht/~ilkecan/indent-rs
max_upload_size
id404519
size26,605
(ilkecan)

documentation

README

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.

Commit count: 0

cargo fmt