Skip to content

Commit e38055e

Browse files
committed
rustfmt the code
1 parent 61cfe6e commit e38055e

File tree

7 files changed

+68
-35
lines changed

7 files changed

+68
-35
lines changed

bin/diffutils/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ fn main() -> Result<(), String> {
4444
&to.to_string_lossy(),
4545
context_count,
4646
),
47-
Format::Ed => ed_diff::diff(
48-
&from_content,
49-
&to_content,
50-
)?,
47+
Format::Ed => ed_diff::diff(&from_content, &to_content)?,
5148
};
5249
io::stdout().write_all(&result).unwrap();
5350
Ok(())

lib/context-diff/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::collections::VecDeque;
22
use std::io::Write;
33

4-
54
#[derive(Debug, PartialEq)]
65
pub enum DiffLine {
76
Context(Vec<u8>),
@@ -232,13 +231,15 @@ fn make_diff(expected: &[u8], actual: &[u8], context_size: usize) -> Vec<Mismatc
232231
for mismatch in &mut results {
233232
if !mismatch
234233
.expected
235-
.iter().any(|x| !matches!(&x, DiffLine::Context(_)))
234+
.iter()
235+
.any(|x| !matches!(&x, DiffLine::Context(_)))
236236
{
237237
mismatch.expected_all_context = true;
238238
}
239239
if !mismatch
240240
.actual
241-
.iter().any(|x| !matches!(&x, DiffLine::Context(_)))
241+
.iter()
242+
.any(|x| !matches!(&x, DiffLine::Context(_)))
242243
{
243244
mismatch.actual_all_context = true;
244245
}

lib/ed-diff/fuzz/fuzz_targets/fuzz_ed.rs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![no_main]
2-
#[macro_use] extern crate libfuzzer_sys;
2+
#[macro_use]
3+
extern crate libfuzzer_sys;
34
extern crate ed_diff;
45

56
use std::fs::{self, File};
@@ -11,16 +12,24 @@ fuzz_target!(|x: (Vec<u8>, Vec<u8>)| {
1112
from.push(b'\n');
1213
to.push(b'\n');
1314
if let Ok(s) = String::from_utf8(from.clone()) {
14-
if !s.is_ascii() { return }
15-
if s.find(|x| x < ' ' && x != '\n').is_some() { return }
15+
if !s.is_ascii() {
16+
return;
17+
}
18+
if s.find(|x| x < ' ' && x != '\n').is_some() {
19+
return;
20+
}
1621
} else {
17-
return
22+
return;
1823
}
1924
if let Ok(s) = String::from_utf8(to.clone()) {
20-
if !s.is_ascii() { return }
21-
if s.find(|x| x < ' ' && x != '\n').is_some() { return }
25+
if !s.is_ascii() {
26+
return;
27+
}
28+
if s.find(|x| x < ' ' && x != '\n').is_some() {
29+
return;
30+
}
2231
} else {
23-
return
32+
return;
2433
}
2534
let diff = ed_diff::diff_w(&from, &to, "target/fuzz.file").unwrap();
2635
File::create("target/fuzz.file.original")
@@ -45,11 +54,18 @@ fuzz_target!(|x: (Vec<u8>, Vec<u8>)| {
4554
.output()
4655
.unwrap();
4756
if !output.status.success() {
48-
panic!("STDOUT:\n{}\nSTDERR:\n{}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr));
57+
panic!(
58+
"STDOUT:\n{}\nSTDERR:\n{}",
59+
String::from_utf8_lossy(&output.stdout),
60+
String::from_utf8_lossy(&output.stderr)
61+
);
4962
}
5063
let result = fs::read("target/fuzz.file").unwrap();
5164
if result != to {
52-
panic!("STDOUT:\n{}\nSTDERR:\n{}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr));
65+
panic!(
66+
"STDOUT:\n{}\nSTDERR:\n{}",
67+
String::from_utf8_lossy(&output.stdout),
68+
String::from_utf8_lossy(&output.stderr)
69+
);
5370
}
5471
});
55-

lib/ed-diff/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,7 @@ pub fn diff(expected: &[u8], actual: &[u8]) -> Result<Vec<u8>, DiffError> {
109109
let actual_count: isize = result.actual.len() as isize;
110110
match (expected_count, actual_count) {
111111
(0, 0) => unreachable!(),
112-
(0, _) => writeln!(
113-
&mut output,
114-
"{}a",
115-
line_number_expected - 1
116-
)
117-
.unwrap(),
112+
(0, _) => writeln!(&mut output, "{}a", line_number_expected - 1).unwrap(),
118113
(_, 0) => writeln!(
119114
&mut output,
120115
"{},{}d",
@@ -230,7 +225,6 @@ fn test_permutations() {
230225
}
231226
}
232227

233-
234228
#[test]
235229
fn test_permutations_empty_lines() {
236230
// test all possible six-line files with missing newlines.

lib/normal-diff/fuzz/fuzz_targets/fuzz_patch.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![no_main]
2-
#[macro_use] extern crate libfuzzer_sys;
2+
#[macro_use]
3+
extern crate libfuzzer_sys;
34
extern crate normal_diff;
45

56
use std::fs::{self, File};
@@ -47,11 +48,18 @@ fuzz_target!(|x: (Vec<u8>, Vec<u8>)| {
4748
.output()
4849
.unwrap();
4950
if !output.status.success() {
50-
panic!("STDOUT:\n{}\nSTDERR:\n{}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr));
51+
panic!(
52+
"STDOUT:\n{}\nSTDERR:\n{}",
53+
String::from_utf8_lossy(&output.stdout),
54+
String::from_utf8_lossy(&output.stderr)
55+
);
5156
}
5257
let result = fs::read("target/fuzz.file").unwrap();
5358
if result != to {
54-
panic!("STDOUT:\n{}\nSTDERR:\n{}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr));
59+
panic!(
60+
"STDOUT:\n{}\nSTDERR:\n{}",
61+
String::from_utf8_lossy(&output.stdout),
62+
String::from_utf8_lossy(&output.stderr)
63+
);
5564
}
5665
});
57-

lib/normal-diff/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ fn make_diff(expected: &[u8], actual: &[u8]) -> Vec<Mismatch> {
6363
line_number_actual += 1;
6464
}
6565
diff::Result::Both(str, _) => {
66-
match (line_number_expected > expected_lines_count, line_number_actual > actual_lines_count) {
66+
match (
67+
line_number_expected > expected_lines_count,
68+
line_number_actual > actual_lines_count,
69+
) {
6770
(true, false) => {
6871
line_number_expected += 1;
6972
line_number_actual += 1;
@@ -88,7 +91,7 @@ fn make_diff(expected: &[u8], actual: &[u8]) -> Vec<Mismatch> {
8891
mismatch.line_number_expected = line_number_expected;
8992
mismatch.line_number_actual = line_number_actual;
9093
}
91-
},
94+
}
9295
}
9396
}
9497
}

lib/unified-diff/fuzz/fuzz_targets/fuzz_patch.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![no_main]
2-
#[macro_use] extern crate libfuzzer_sys;
2+
#[macro_use]
3+
extern crate libfuzzer_sys;
34
extern crate unified_diff;
45

56
use std::fs::{self, File};
@@ -20,7 +21,13 @@ fuzz_target!(|x: (Vec<u8>, Vec<u8>, u8)| {
2021
} else {
2122
return
2223
}*/
23-
let diff = unified_diff::diff(&from, "a/fuzz.file", &to, "target/fuzz.file", context as usize);
24+
let diff = unified_diff::diff(
25+
&from,
26+
"a/fuzz.file",
27+
&to,
28+
"target/fuzz.file",
29+
context as usize,
30+
);
2431
File::create("target/fuzz.file.original")
2532
.unwrap()
2633
.write_all(&from)
@@ -45,11 +52,18 @@ fuzz_target!(|x: (Vec<u8>, Vec<u8>, u8)| {
4552
.output()
4653
.unwrap();
4754
if !output.status.success() {
48-
panic!("STDOUT:\n{}\nSTDERR:\n{}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr));
55+
panic!(
56+
"STDOUT:\n{}\nSTDERR:\n{}",
57+
String::from_utf8_lossy(&output.stdout),
58+
String::from_utf8_lossy(&output.stderr)
59+
);
4960
}
5061
let result = fs::read("target/fuzz.file").unwrap();
5162
if result != to {
52-
panic!("STDOUT:\n{}\nSTDERR:\n{}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr));
63+
panic!(
64+
"STDOUT:\n{}\nSTDERR:\n{}",
65+
String::from_utf8_lossy(&output.stdout),
66+
String::from_utf8_lossy(&output.stderr)
67+
);
5368
}
5469
});
55-

0 commit comments

Comments
 (0)