Skip to content

Commit 416cd79

Browse files
committed
formatting
1 parent 392619c commit 416cd79

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

text/diff_util/change.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub enum Change {
2121
}
2222

2323
impl Change {
24-
2524
pub fn get_ln1(&self) -> usize {
2625
match self {
2726
Change::None => panic!("Change::None is not allowed in hunk."),

text/diff_util/dir_diff.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,15 @@ impl<'a> DirDiff<'a> {
4848
let is_file = dir_data
4949
.files()
5050
.get_key_value(file_name)
51-
.unwrap_or_else(|| panic!("Could not find file in {}",
51+
.unwrap_or_else(|| {
52+
panic!(
53+
"Could not find file in {}",
5254
dir_data
53-
.path()
54-
.to_str()
55-
.unwrap_or(COULD_NOT_UNWRAP_FILENAME)))
55+
.path()
56+
.to_str()
57+
.unwrap_or(COULD_NOT_UNWRAP_FILENAME)
58+
)
59+
})
5660
.1
5761
.file_type()?
5862
.is_file();

text/diff_util/file_data.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
use std::{
2-
fs::File,
3-
io,
4-
mem::take,
5-
path::PathBuf,
6-
str::from_utf8,
7-
time::SystemTime,
8-
};
1+
use std::{fs::File, io, mem::take, path::PathBuf, str::from_utf8, time::SystemTime};
92

103
use super::constants::COULD_NOT_UNWRAP_FILENAME;
114

@@ -22,7 +15,11 @@ impl<'a> FileData<'a> {
2215
self.ends_with_newline
2316
}
2417

25-
pub fn get_file(path: PathBuf, lines: Vec<&'a str>, ends_with_newline: bool) -> io::Result<Self> {
18+
pub fn get_file(
19+
path: PathBuf,
20+
lines: Vec<&'a str>,
21+
ends_with_newline: bool,
22+
) -> io::Result<Self> {
2623
let file = File::open(&path)?;
2724
let modified = file.metadata()?.modified()?;
2825

@@ -69,7 +66,10 @@ pub struct LineReader<'a> {
6966
impl<'a> LineReader<'a> {
7067
pub fn new(content: &'a [u8]) -> Self {
7168
let ends_with_newline = content.last() == Some(&b'\n');
72-
Self { content, ends_with_newline }
69+
Self {
70+
content,
71+
ends_with_newline,
72+
}
7373
}
7474
pub fn ends_with_newline(&self) -> bool {
7575
self.ends_with_newline
@@ -100,5 +100,4 @@ impl<'a> Iterator for LineReader<'a> {
100100
self.content = rest;
101101
Some(from_utf8(&line[..line_len - 1]).expect("Failed to convert to str"))
102102
}
103-
104103
}

text/diff_util/hunks.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl Hunk {
3939
} else if is_ed && (self.ln1_start == self.ln1_end - 1) {
4040
format!("{}", self.ln1_end)
4141
} else {
42-
format!("{},{}", self.ln1_start+1, self.ln1_end)
42+
format!("{},{}", self.ln1_start + 1, self.ln1_end)
4343
}
4444
}
4545

@@ -49,7 +49,7 @@ impl Hunk {
4949
} else if is_ed && (self.ln2_start == self.ln2_end - 1) {
5050
format!("{}", self.ln2_end)
5151
} else {
52-
format!("{},{}", self.ln2_start+1, self.ln2_end)
52+
format!("{},{}", self.ln2_start + 1, self.ln2_end)
5353
}
5454
}
5555

@@ -213,7 +213,10 @@ pub struct Hunks {
213213
impl Hunks {
214214
pub fn new() -> Self {
215215
Self {
216-
hunks: { Hunk::new(); vec![] as Vec<Hunk>},
216+
hunks: {
217+
Hunk::new();
218+
vec![] as Vec<Hunk>
219+
},
217220
}
218221
}
219222

@@ -253,7 +256,11 @@ impl Hunks {
253256
} else {
254257
(prev_val + 1) as usize
255258
};
256-
} else if (i != 0) && (prev_val != -1) && (lcs_index != &-1) && (lcs_index != &(prev_val + 1)) {
259+
} else if (i != 0)
260+
&& (prev_val != -1)
261+
&& (lcs_index != &-1)
262+
&& (lcs_index != &(prev_val + 1))
263+
{
257264
// there was an insertion (but no deletion)
258265
// no -1 values but a bump in the values, eg [136, 145]
259266
hunk_start1 = i;

0 commit comments

Comments
 (0)