Skip to content

Commit 0898b44

Browse files
committed
style: clippy autofix
1 parent 4706cb7 commit 0898b44

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/ffmpeg.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn run_command(command: &str) {
2424

2525
pub fn create_preview_image(input: String, output: String) {
2626
let path = format!("{}/lg", output);
27-
if !fs::metadata(&path).is_ok() {
27+
if fs::metadata(&path).is_err() {
2828
fs::create_dir_all(&path).unwrap();
2929
}
3030

@@ -42,7 +42,7 @@ pub fn create_thumbnails(input: String, output: String) {
4242
let thumbs_path = format!("{}/thumbs", output);
4343

4444
println!("Path: {}", thumbs_path);
45-
if !fs::metadata(&thumbs_path).is_ok() {
45+
if fs::metadata(&thumbs_path).is_err() {
4646
fs::create_dir_all(&thumbs_path).unwrap();
4747
}
4848

@@ -57,7 +57,7 @@ pub fn create_thumbnails(input: String, output: String) {
5757
pub fn create_hls_encoding(input: String, output: String) {
5858
println!("\npub create_hls_encoding");
5959

60-
if !fs::metadata(&output).is_ok() {
60+
if fs::metadata(&output).is_err() {
6161
fs::create_dir_all(&output).unwrap();
6262
}
6363

src/fileio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ use std::fs::File;
44
use std::io::Write;
55

66
pub fn file_to_hyphen(name: &String) -> String {
7-
return String::from(name.replace("_", "-").replace(" ", "-").replace(".", "-"));
7+
name.replace(['_', ' ', '.'], "-")
88
}
99

1010
pub fn write_metadata(data: &OutputMetadata) {
1111
let directory = file_to_hyphen(&data.title);
1212

13-
if !fs::metadata(&directory).is_ok() {
13+
if fs::metadata(&directory).is_err() {
1414
fs::create_dir(&directory).unwrap();
1515
}
1616

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn main() {
9191
process::exit(1);
9292
}
9393

94-
let out = media_info::get_media_info(&input);
94+
let out = media_info::get_media_info(input);
9595
println!("{:#?}", &out);
9696
fileio::write_metadata(&out);
9797

@@ -109,7 +109,7 @@ fn main() {
109109

110110
let gen_hls = matches.is_present(Flags::HLS.as_str());
111111
if gen_hls {
112-
create_hls_encoding(out.file_name.clone(), path.clone());
112+
create_hls_encoding(out.file_name, path);
113113
}
114114

115115
/*

src/media_info.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn get_file_parts(file: &str) -> (&str, &str, &str) {
1616
}
1717

1818
pub fn get_media_info(input: &str) -> OutputMetadata {
19-
if !fs::metadata(&input).is_ok() {
19+
if fs::metadata(input).is_err() {
2020
println!("{} is not found.", &input);
2121
std::process::exit(1);
2222
}
@@ -25,7 +25,7 @@ pub fn get_media_info(input: &str) -> OutputMetadata {
2525

2626
let media_info = Command::new("mediainfo")
2727
.arg("--output=JSON")
28-
.arg(format!("{}", input))
28+
.arg(input)
2929
.output()
3030
.expect("mediainfo error parsing file, make sure mediainfo is installed");
3131

@@ -75,7 +75,7 @@ pub fn get_media_info(input: &str) -> OutputMetadata {
7575
}
7676
}
7777

78-
return metadata;
78+
metadata
7979
}
8080

8181
#[test]

0 commit comments

Comments
 (0)