File: README.md

package info (click to toggle)
rust-file-diff 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 832 kB
  • sloc: makefile: 14
file content (31 lines) | stat: -rw-r--r-- 735 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File Diff

This module provides an atomic file diffing function for use in unit tests.

The diff\_files() function takes two file handles and determines returns true
if they point to identical files.

```rust
use file_diff::{diff_files};
use std::fs::{File};

let mut file1 = match File::open("./src/lib.rs") {
    Ok(f) => f,
    Err(e) => panic!("{}", e),
};
let mut file2 = match File::open("./src/lib.rs") {
    Ok(f) => f,
    Err(e) => panic!("{}", e),
};

diff_files(&mut file1, &mut file2);
```

The diff() function takes string representations of the files and returns true
if the strings represent real files and those files are identical.

```rust
use file_diff::{diff};

diff("./src/lib.rs", "./src/lib.rs"); // true
```