Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
TanmayPatil105 committed May 5, 2024
1 parent b8001cc commit 4482bdb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/context_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ fn make_diff(
#[must_use]
pub fn diff(expected: &[u8], actual: &[u8], params: &Params) -> Vec<u8> {
let from_modified_time =
match !params.stdin_path.is_empty() && params.from.to_string_lossy().starts_with("-") {
match !params.stdin_path.is_empty() && params.from.to_string_lossy().starts_with('-') {
true => get_modification_time(&params.stdin_path.to_string_lossy()),

Check warning on line 273 in src/context_diff.rs

View check run for this annotation

Codecov / codecov/patch

src/context_diff.rs#L273

Added line #L273 was not covered by tests
false => get_modification_time(&params.from.to_string_lossy()),
};
let to_modified_time =
match !params.stdin_path.is_empty() && params.to.to_string_lossy().starts_with("-") {
match !params.stdin_path.is_empty() && params.to.to_string_lossy().starts_with('-') {
true => get_modification_time(&params.stdin_path.to_string_lossy()),

Check warning on line 278 in src/context_diff.rs

View check run for this annotation

Codecov / codecov/patch

src/context_diff.rs#L278

Added line #L278 was not covered by tests
false => get_modification_time(&params.to.to_string_lossy()),
};
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn main() -> ExitCode {
}
// read files
fn read_file_contents(filepath: &OsString, stdin_path: &OsString) -> io::Result<Vec<u8>> {
if filepath.to_string_lossy().starts_with("-") && !stdin_path.is_empty() {
if filepath.to_string_lossy().starts_with('-') && !stdin_path.is_empty() {
fs::read(stdin_path)

Check warning on line 51 in src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/main.rs#L51

Added line #L51 was not covered by tests
} else if filepath == "-" {
let mut content = Vec::new();
Expand Down
7 changes: 3 additions & 4 deletions src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,11 @@ pub fn parse_params<I: IntoIterator<Item = OsString>>(opts: I) -> Result<Params,
let file = File::from(fd);
let meta = file.metadata().unwrap();
if meta.is_dir() {
let stdin = fs::canonicalize("/dev/stdin").unwrap();
let mut stdin_path: PathBuf = PathBuf::from(stdin);
let mut stdin_path = fs::canonicalize("/dev/stdin").unwrap();

Check warning on line 193 in src/params.rs

View check run for this annotation

Codecov / codecov/patch

src/params.rs#L193

Added line #L193 was not covered by tests
if params.from == "-" {
stdin_path.push(&to_path.file_name().unwrap());
stdin_path.push(to_path.file_name().unwrap());

Check warning on line 195 in src/params.rs

View check run for this annotation

Codecov / codecov/patch

src/params.rs#L195

Added line #L195 was not covered by tests
} else {
stdin_path.push(&from_path.file_name().unwrap());
stdin_path.push(from_path.file_name().unwrap());

Check warning on line 197 in src/params.rs

View check run for this annotation

Codecov / codecov/patch

src/params.rs#L197

Added line #L197 was not covered by tests
}
params.stdin_path = stdin_path.into();

Check warning on line 199 in src/params.rs

View check run for this annotation

Codecov / codecov/patch

src/params.rs#L199

Added line #L199 was not covered by tests
}
Expand Down
4 changes: 2 additions & 2 deletions src/unified_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ fn make_diff(
#[must_use]
pub fn diff(expected: &[u8], actual: &[u8], params: &Params) -> Vec<u8> {
let from_modified_time =
match !params.stdin_path.is_empty() && params.from.to_string_lossy().starts_with("-") {
match !params.stdin_path.is_empty() && params.from.to_string_lossy().starts_with('-') {
true => get_modification_time(&params.stdin_path.to_string_lossy()),

Check warning on line 244 in src/unified_diff.rs

View check run for this annotation

Codecov / codecov/patch

src/unified_diff.rs#L244

Added line #L244 was not covered by tests
false => get_modification_time(&params.from.to_string_lossy()),
};
let to_modified_time =
match !params.stdin_path.is_empty() && params.to.to_string_lossy().starts_with("-") {
match !params.stdin_path.is_empty() && params.to.to_string_lossy().starts_with('-') {
true => get_modification_time(&params.stdin_path.to_string_lossy()),

Check warning on line 249 in src/unified_diff.rs

View check run for this annotation

Codecov / codecov/patch

src/unified_diff.rs#L249

Added line #L249 was not covered by tests
false => get_modification_time(&params.to.to_string_lossy()),
};
Expand Down

0 comments on commit 4482bdb

Please sign in to comment.