| 1 | # File Diff |
| 2 | |
| 3 | This module provides an atomic file diffing function for use in unit tests. |
| 4 | |
| 5 | The diff\_files() function takes two file handles and determines returns true |
| 6 | if they point to identical files. |
| 7 | |
| 8 | ```rust |
| 9 | use file_diff::{diff_files}; |
| 10 | use std::fs::{File}; |
| 11 | |
| 12 | let mut file1 = match File::open("./src/lib.rs") { |
| 13 | Ok(f) => f, |
| 14 | Err(e) => panic!("{}", e), |
| 15 | }; |
| 16 | let mut file2 = match File::open("./src/lib.rs") { |
| 17 | Ok(f) => f, |
| 18 | Err(e) => panic!("{}", e), |
| 19 | }; |
| 20 | |
| 21 | diff_files(&mut file1, &mut file2); |
| 22 | ``` |
| 23 | |
| 24 | The diff() function takes string representations of the files and returns true |
| 25 | if the strings represent real files and those files are identical. |
| 26 | |
| 27 | ```rust |
| 28 | use file_diff::{diff}; |
| 29 | |
| 30 | diff("./src/lib.rs", "./src/lib.rs"); // true |
| 31 | ``` |