@@ -18,14 +18,14 @@ enum Browser {
1818
1919#[ derive( Parser , Debug , Clone , Copy , ValueEnum ) ]
2020enum Method {
21- GET ,
22- POST ,
23- PUT ,
24- DELETE ,
25- PATCH ,
26- HEAD ,
27- OPTIONS ,
28- TRACE ,
21+ Get ,
22+ Post ,
23+ Put ,
24+ Delete ,
25+ Patch ,
26+ Head ,
27+ Options ,
28+ Trace ,
2929}
3030
3131/// CLI interface for the impit library.
@@ -113,17 +113,11 @@ async fn main() {
113113 client = client. with_redirect ( RedirectBehavior :: ManualRedirect ) ;
114114 }
115115
116- let body: Option < Vec < u8 > > = match args. data {
117- Some ( data) => Some ( data. into_string ( ) . unwrap ( ) . into_bytes ( ) ) ,
118- None => None ,
119- } ;
116+ let body: Option < Vec < u8 > > = args. data . map ( |data| data. into_string ( ) . unwrap ( ) . into_bytes ( ) ) ;
120117
121118 let mut client = client. build ( ) ;
122119
123- let timeout = match args. max_time {
124- Some ( time) => Some ( std:: time:: Duration :: from_secs ( time) ) ,
125- None => None ,
126- } ;
120+ let timeout = args. max_time . map ( std:: time:: Duration :: from_secs) ;
127121
128122 let options = RequestOptions {
129123 headers : headers:: process_headers ( args. headers ) ,
@@ -132,14 +126,14 @@ async fn main() {
132126 } ;
133127
134128 let response = match args. method {
135- Method :: GET => client. get ( args. url , Some ( options) ) . await . unwrap ( ) ,
136- Method :: POST => client. post ( args. url , body, Some ( options) ) . await . unwrap ( ) ,
137- Method :: PUT => client. put ( args. url , body, Some ( options) ) . await . unwrap ( ) ,
138- Method :: DELETE => client. delete ( args. url , Some ( options) ) . await . unwrap ( ) ,
139- Method :: PATCH => client. patch ( args. url , body, Some ( options) ) . await . unwrap ( ) ,
140- Method :: HEAD => client. head ( args. url , Some ( options) ) . await . unwrap ( ) ,
141- Method :: OPTIONS => client. options ( args. url , Some ( options) ) . await . unwrap ( ) ,
142- Method :: TRACE => client. trace ( args. url , Some ( options) ) . await . unwrap ( ) ,
129+ Method :: Get => client. get ( args. url , Some ( options) ) . await . unwrap ( ) ,
130+ Method :: Post => client. post ( args. url , body, Some ( options) ) . await . unwrap ( ) ,
131+ Method :: Put => client. put ( args. url , body, Some ( options) ) . await . unwrap ( ) ,
132+ Method :: Delete => client. delete ( args. url , Some ( options) ) . await . unwrap ( ) ,
133+ Method :: Patch => client. patch ( args. url , body, Some ( options) ) . await . unwrap ( ) ,
134+ Method :: Head => client. head ( args. url , Some ( options) ) . await . unwrap ( ) ,
135+ Method :: Options => client. options ( args. url , Some ( options) ) . await . unwrap ( ) ,
136+ Method :: Trace => client. trace ( args. url , Some ( options) ) . await . unwrap ( ) ,
143137 } ;
144138
145139 print ! ( "{}" , response. text( ) . await . unwrap( ) ) ;
0 commit comments