file-editor 0.2.0

Clean, elegant API for creating and editing text files
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use file_editor::utils::line_indent;

#[test]
fn indent_first_line() {
    let txt = "   abc\nnext";
    let pos = txt.find('a').unwrap();
    assert_eq!(line_indent(txt, pos), "   ");
}

#[test]
fn indent_after_newline() {
    let txt = "no indent\n\t\txyz";
    let pos = txt.find('x').unwrap();
    assert_eq!(line_indent(txt, pos), "\t\t");
}