@@ -1343,7 +1343,7 @@ impl<H> Easy2<H> {
1343
1343
/// `CURLOPT_POSTFIELDSIZE_LARGE`.
1344
1344
pub fn post_field_size ( & mut self , size : u64 ) -> Result < ( ) , Error > {
1345
1345
// 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 ( ) ) ?;
1347
1347
self . setopt_off_t (
1348
1348
curl_sys:: CURLOPT_POSTFIELDSIZE_LARGE ,
1349
1349
size as curl_sys:: curl_off_t ,
@@ -1738,7 +1738,7 @@ impl<H> Easy2<H> {
1738
1738
pub fn timeout ( & mut self , timeout : Duration ) -> Result < ( ) , Error > {
1739
1739
// TODO: checked arithmetic and casts
1740
1740
// 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 ;
1742
1742
self . setopt_long ( curl_sys:: CURLOPT_TIMEOUT_MS , ms as c_long )
1743
1743
}
1744
1744
@@ -1860,7 +1860,7 @@ impl<H> Easy2<H> {
1860
1860
/// By default this value is 300 seconds and corresponds to
1861
1861
/// `CURLOPT_CONNECTTIMEOUT_MS`.
1862
1862
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 ;
1864
1864
self . setopt_long ( curl_sys:: CURLOPT_CONNECTTIMEOUT_MS , ms as c_long )
1865
1865
}
1866
1866
@@ -2411,7 +2411,7 @@ impl<H> Easy2<H> {
2411
2411
/// By default this option is not set and corresponds to
2412
2412
/// `CURLOPT_EXPECT_100_TIMEOUT_MS`.
2413
2413
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 ;
2415
2415
self . setopt_long ( curl_sys:: CURLOPT_EXPECT_100_TIMEOUT_MS , ms as c_long )
2416
2416
}
2417
2417
@@ -2422,15 +2422,8 @@ impl<H> Easy2<H> {
2422
2422
//// This corresponds to `CURLINFO_CONDITION_UNMET` and may return an error if the
2423
2423
/// option is not supported
2424
2424
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 )
2434
2427
}
2435
2428
2436
2429
/// Get the last used URL
@@ -2894,7 +2887,7 @@ impl<H> Easy2<H> {
2894
2887
2895
2888
/// URL encodes a string `s`
2896
2889
pub fn url_encode ( & mut self , s : & [ u8 ] ) -> String {
2897
- if s. len ( ) == 0 {
2890
+ if s. is_empty ( ) {
2898
2891
return String :: new ( ) ;
2899
2892
}
2900
2893
unsafe {
@@ -2913,7 +2906,7 @@ impl<H> Easy2<H> {
2913
2906
2914
2907
/// URL decodes a string `s`, returning `None` if it fails
2915
2908
pub fn url_decode ( & mut self , s : & str ) -> Vec < u8 > {
2916
- if s. len ( ) == 0 {
2909
+ if s. is_empty ( ) {
2917
2910
return Vec :: new ( ) ;
2918
2911
}
2919
2912
@@ -3078,7 +3071,7 @@ impl<H> Easy2<H> {
3078
3071
3079
3072
fn getopt_ptr ( & mut self , opt : curl_sys:: CURLINFO ) -> Result < * const c_char , Error > {
3080
3073
unsafe {
3081
- let mut p = 0 as * const c_char ;
3074
+ let mut p = ptr :: null ( ) ;
3082
3075
let rc = curl_sys:: curl_easy_getinfo ( self . inner . handle , opt, & mut p) ;
3083
3076
self . cvt ( rc) ?;
3084
3077
Ok ( p)
0 commit comments