@@ -1343,7 +1343,7 @@ impl<H> Easy2<H> {
13431343 /// `CURLOPT_POSTFIELDSIZE_LARGE`.
13441344 pub fn post_field_size ( & mut self , size : u64 ) -> Result < ( ) , Error > {
13451345 // Clear anything previous to ensure we don't read past a buffer
1346- self . setopt_ptr ( curl_sys:: CURLOPT_POSTFIELDS , 0 as * const _ ) ?;
1346+ self . setopt_ptr ( curl_sys:: CURLOPT_POSTFIELDS , ptr :: null ( ) ) ?;
13471347 self . setopt_off_t (
13481348 curl_sys:: CURLOPT_POSTFIELDSIZE_LARGE ,
13491349 size as curl_sys:: curl_off_t ,
@@ -1738,7 +1738,7 @@ impl<H> Easy2<H> {
17381738 pub fn timeout ( & mut self , timeout : Duration ) -> Result < ( ) , Error > {
17391739 // TODO: checked arithmetic and casts
17401740 // TODO: use CURLOPT_TIMEOUT if the timeout is too great
1741- let ms = timeout. as_secs ( ) * 1000 + ( timeout. subsec_nanos ( ) / 1_000_000 ) as u64 ;
1741+ let ms = timeout. as_secs ( ) * 1000 + timeout. subsec_millis ( ) as u64 ;
17421742 self . setopt_long ( curl_sys:: CURLOPT_TIMEOUT_MS , ms as c_long )
17431743 }
17441744
@@ -1860,7 +1860,7 @@ impl<H> Easy2<H> {
18601860 /// By default this value is 300 seconds and corresponds to
18611861 /// `CURLOPT_CONNECTTIMEOUT_MS`.
18621862 pub fn connect_timeout ( & mut self , timeout : Duration ) -> Result < ( ) , Error > {
1863- let ms = timeout. as_secs ( ) * 1000 + ( timeout. subsec_nanos ( ) / 1_000_000 ) as u64 ;
1863+ let ms = timeout. as_secs ( ) * 1000 + timeout. subsec_millis ( ) as u64 ;
18641864 self . setopt_long ( curl_sys:: CURLOPT_CONNECTTIMEOUT_MS , ms as c_long )
18651865 }
18661866
@@ -2411,7 +2411,7 @@ impl<H> Easy2<H> {
24112411 /// By default this option is not set and corresponds to
24122412 /// `CURLOPT_EXPECT_100_TIMEOUT_MS`.
24132413 pub fn expect_100_timeout ( & mut self , timeout : Duration ) -> Result < ( ) , Error > {
2414- let ms = timeout. as_secs ( ) * 1000 + ( timeout. subsec_nanos ( ) / 1_000_000 ) as u64 ;
2414+ let ms = timeout. as_secs ( ) * 1000 + timeout. subsec_millis ( ) as u64 ;
24152415 self . setopt_long ( curl_sys:: CURLOPT_EXPECT_100_TIMEOUT_MS , ms as c_long )
24162416 }
24172417
@@ -2422,15 +2422,8 @@ impl<H> Easy2<H> {
24222422 //// This corresponds to `CURLINFO_CONDITION_UNMET` and may return an error if the
24232423 /// option is not supported
24242424 pub fn time_condition_unmet ( & mut self ) -> Result < bool , Error > {
2425- self . getopt_long ( curl_sys:: CURLINFO_CONDITION_UNMET ) . map (
2426- |r| {
2427- if r == 0 {
2428- false
2429- } else {
2430- true
2431- }
2432- } ,
2433- )
2425+ self . getopt_long ( curl_sys:: CURLINFO_CONDITION_UNMET )
2426+ . map ( |r| r != 0 )
24342427 }
24352428
24362429 /// Get the last used URL
@@ -2894,7 +2887,7 @@ impl<H> Easy2<H> {
28942887
28952888 /// URL encodes a string `s`
28962889 pub fn url_encode ( & mut self , s : & [ u8 ] ) -> String {
2897- if s. len ( ) == 0 {
2890+ if s. is_empty ( ) {
28982891 return String :: new ( ) ;
28992892 }
29002893 unsafe {
@@ -2913,7 +2906,7 @@ impl<H> Easy2<H> {
29132906
29142907 /// URL decodes a string `s`, returning `None` if it fails
29152908 pub fn url_decode ( & mut self , s : & str ) -> Vec < u8 > {
2916- if s. len ( ) == 0 {
2909+ if s. is_empty ( ) {
29172910 return Vec :: new ( ) ;
29182911 }
29192912
@@ -3078,7 +3071,7 @@ impl<H> Easy2<H> {
30783071
30793072 fn getopt_ptr ( & mut self , opt : curl_sys:: CURLINFO ) -> Result < * const c_char , Error > {
30803073 unsafe {
3081- let mut p = 0 as * const c_char ;
3074+ let mut p = ptr :: null ( ) ;
30823075 let rc = curl_sys:: curl_easy_getinfo ( self . inner . handle , opt, & mut p) ;
30833076 self . cvt ( rc) ?;
30843077 Ok ( p)
0 commit comments