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
use file_editor::Editor;

#[test]
fn save_when_not_dirty_is_noop() -> std::io::Result<()> {
    let dir = tempfile::tempdir()?;
    let p = dir.path().join("noop.txt");

    Editor::create(&p)? // dirty = false
        .save()?; // hit the else-branch

    assert_eq!(std::fs::read_to_string(p)?, "");
    Ok(())
}