dots_internal_utils 0.5.0

A set of utility modules intended to be used internally by the dots crate
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/// takes the given string and indents every line by the given number of spaces
pub fn indent(spaces: usize, string: &str) -> String {
    let has_extra_newline = string.ends_with('\n');
    let lines: Vec<String> = string
        .lines()
        .map(|line| format!("{spaces}{line}", spaces = " ".repeat(spaces)))
        .collect();

    let string = lines.join("\n");

    if has_extra_newline {
        format!("{string}\n")
    } else {
        string
    }
}