File tree Expand file tree Collapse file tree 3 files changed +12
-13
lines changed Expand file tree Collapse file tree 3 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use std::fs;
3
3
use std:: fs:: File ;
4
4
use std:: io:: Write ;
5
5
6
- pub fn file_to_hyphen ( name : & String ) -> String {
6
+ pub fn file_to_hyphen ( name : & str ) -> String {
7
7
name. replace ( [ '_' , ' ' , '.' ] , "-" )
8
8
}
9
9
@@ -22,6 +22,6 @@ pub fn write_metadata(data: &OutputMetadata) {
22
22
23
23
#[ test]
24
24
fn file_to_hyphen_test ( ) {
25
- let result = file_to_hyphen ( & "2022.04.06.name with space.mp4" . to_string ( ) ) ;
25
+ let result = file_to_hyphen ( "2022.04.06.name with space.mp4" ) ;
26
26
assert_eq ! ( result, "2022-04-06-name-with-space-mp4" ) ;
27
27
}
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use std::process;
4
4
5
5
enum Flags {
6
6
_Gif,
7
- HLS ,
7
+ Hls ,
8
8
_Metadata,
9
9
PreviewImage ,
10
10
Thumbnails ,
@@ -32,7 +32,7 @@ impl Flags {
32
32
fn as_str ( & self ) -> & ' static str {
33
33
match self {
34
34
Flags :: _Gif => "gif" ,
35
- Flags :: HLS => "HLS" ,
35
+ Flags :: Hls => "HLS" ,
36
36
Flags :: _Metadata => "metadata" ,
37
37
Flags :: PreviewImage => "preview_image" ,
38
38
Flags :: Thumbnails => "thumbs" ,
@@ -77,9 +77,9 @@ fn main() {
77
77
. takes_value ( false ) ,
78
78
)
79
79
. arg (
80
- Arg :: with_name ( Flags :: HLS . as_str ( ) )
80
+ Arg :: with_name ( Flags :: Hls . as_str ( ) )
81
81
. short ( 'h' )
82
- . long ( Flags :: HLS . as_str ( ) )
82
+ . long ( Flags :: Hls . as_str ( ) )
83
83
. help ( "Generate hls chunks" )
84
84
. takes_value ( false ) ,
85
85
)
@@ -107,7 +107,7 @@ fn main() {
107
107
create_preview_image ( out. file_name . clone ( ) , path. clone ( ) ) ;
108
108
}
109
109
110
- let gen_hls = matches. is_present ( Flags :: HLS . as_str ( ) ) ;
110
+ let gen_hls = matches. is_present ( Flags :: Hls . as_str ( ) ) ;
111
111
if gen_hls {
112
112
create_hls_encoding ( out. file_name , path) ;
113
113
}
Original file line number Diff line number Diff line change @@ -64,13 +64,12 @@ pub fn get_media_info(input: &str) -> OutputMetadata {
64
64
metadata. duration_human = duration. duration_human ( ) ;
65
65
metadata. frame_rate = track. frame_rate . parse ( ) . unwrap ( ) ;
66
66
67
- match track. width {
68
- Some ( width) => metadata. width = width. parse ( ) . unwrap ( ) ,
69
- None => { }
67
+ if let Some ( width) = track. width {
68
+ metadata. width = width. parse ( ) . unwrap ( )
70
69
}
71
- match track . height {
72
- Some ( height) => metadata . height = height . parse ( ) . unwrap ( ) ,
73
- None => { }
70
+
71
+ if let Some ( height) = track . height {
72
+ metadata . height = height . parse ( ) . unwrap ( )
74
73
}
75
74
}
76
75
}
You can’t perform that action at this time.
0 commit comments