Skip to content

Commit 720ca91

Browse files
committed
Fix nightly deprecation warnings
1 parent 0117ecc commit 720ca91

File tree

6 files changed

+81
-81
lines changed

6 files changed

+81
-81
lines changed

src/easy/handle.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ unsafe impl Send for EasyData {}
105105

106106
#[derive(Default)]
107107
struct Callbacks<'a> {
108-
write: Option<Box<FnMut(&[u8]) -> Result<usize, WriteError> + 'a>>,
109-
read: Option<Box<FnMut(&mut [u8]) -> Result<usize, ReadError> + 'a>>,
110-
seek: Option<Box<FnMut(SeekFrom) -> SeekResult + 'a>>,
111-
debug: Option<Box<FnMut(InfoType, &[u8]) + 'a>>,
112-
header: Option<Box<FnMut(&[u8]) -> bool + 'a>>,
113-
progress: Option<Box<FnMut(f64, f64, f64, f64) -> bool + 'a>>,
114-
ssl_ctx: Option<Box<FnMut(*mut c_void) -> Result<(), Error> + 'a>>,
108+
write: Option<Box<dyn FnMut(&[u8]) -> Result<usize, WriteError> + 'a>>,
109+
read: Option<Box<dyn FnMut(&mut [u8]) -> Result<usize, ReadError> + 'a>>,
110+
seek: Option<Box<dyn FnMut(SeekFrom) -> SeekResult + 'a>>,
111+
debug: Option<Box<dyn FnMut(InfoType, &[u8]) + 'a>>,
112+
header: Option<Box<dyn FnMut(&[u8]) -> bool + 'a>>,
113+
progress: Option<Box<dyn FnMut(f64, f64, f64, f64) -> bool + 'a>>,
114+
ssl_ctx: Option<Box<dyn FnMut(*mut c_void) -> Result<(), Error> + 'a>>,
115115
}
116116

117117
impl Easy {

src/easy/handler.rs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ impl<H> Easy2<H> {
788788
/// /path/file.sock
789789
/// ```
790790
pub fn unix_socket(&mut self, unix_domain_socket: &str) -> Result<(), Error> {
791-
let socket = try!(CString::new(unix_domain_socket));
791+
let socket = CString::new(unix_domain_socket)?;
792792
self.setopt_str(curl_sys::CURLOPT_UNIX_SOCKET_PATH, &socket)
793793
}
794794

@@ -837,7 +837,7 @@ impl<H> Easy2<H> {
837837
/// By default this option is not set and `perform` will not work until it
838838
/// is set. This option corresponds to `CURLOPT_URL`.
839839
pub fn url(&mut self, url: &str) -> Result<(), Error> {
840-
let url = try!(CString::new(url));
840+
let url = CString::new(url)?;
841841
self.setopt_str(curl_sys::CURLOPT_URL, &url)
842842
}
843843

@@ -858,7 +858,7 @@ impl<H> Easy2<H> {
858858
///
859859
/// By default this option is not set and corresponds to `CURLOPT_PROXY`.
860860
pub fn proxy(&mut self, url: &str) -> Result<(), Error> {
861-
let url = try!(CString::new(url));
861+
let url = CString::new(url)?;
862862
self.setopt_str(curl_sys::CURLOPT_PROXY, &url)
863863
}
864864

@@ -887,7 +887,7 @@ impl<H> Easy2<H> {
887887
/// By default this option is not set and corresponds to
888888
/// `CURLOPT_NOPROXY`.
889889
pub fn noproxy(&mut self, skip: &str) -> Result<(), Error> {
890-
let skip = try!(CString::new(skip));
890+
let skip = CString::new(skip)?;
891891
self.setopt_str(curl_sys::CURLOPT_NOPROXY, &skip)
892892
}
893893

@@ -909,7 +909,7 @@ impl<H> Easy2<H> {
909909
/// By default this option is not set and corresponds to
910910
/// `CURLOPT_INTERFACE`.
911911
pub fn interface(&mut self, interface: &str) -> Result<(), Error> {
912-
let s = try!(CString::new(interface));
912+
let s = CString::new(interface)?;
913913
self.setopt_str(curl_sys::CURLOPT_INTERFACE, &s)
914914
}
915915

@@ -939,7 +939,7 @@ impl<H> Easy2<H> {
939939
/// [c-ares](https://c-ares.haxx.se), otherwise setting it will return
940940
/// an error.
941941
pub fn dns_servers(&mut self, servers: &str) -> Result<(), Error> {
942-
let s = try!(CString::new(servers));
942+
let s = CString::new(servers)?;
943943
self.setopt_str(curl_sys::CURLOPT_DNS_SERVERS, &s)
944944
}
945945

@@ -1030,15 +1030,15 @@ impl<H> Easy2<H> {
10301030
///
10311031
/// By default this value is not set and corresponds to `CURLOPT_USERNAME`.
10321032
pub fn username(&mut self, user: &str) -> Result<(), Error> {
1033-
let user = try!(CString::new(user));
1033+
let user = CString::new(user)?;
10341034
self.setopt_str(curl_sys::CURLOPT_USERNAME, &user)
10351035
}
10361036

10371037
/// Configures the password to pass as authentication for this connection.
10381038
///
10391039
/// By default this value is not set and corresponds to `CURLOPT_PASSWORD`.
10401040
pub fn password(&mut self, pass: &str) -> Result<(), Error> {
1041-
let pass = try!(CString::new(pass));
1041+
let pass = CString::new(pass)?;
10421042
self.setopt_str(curl_sys::CURLOPT_PASSWORD, &pass)
10431043
}
10441044

@@ -1063,7 +1063,7 @@ impl<H> Easy2<H> {
10631063
/// By default this value is not set and corresponds to
10641064
/// `CURLOPT_PROXYUSERNAME`.
10651065
pub fn proxy_username(&mut self, user: &str) -> Result<(), Error> {
1066-
let user = try!(CString::new(user));
1066+
let user = CString::new(user)?;
10671067
self.setopt_str(curl_sys::CURLOPT_PROXYUSERNAME, &user)
10681068
}
10691069

@@ -1073,7 +1073,7 @@ impl<H> Easy2<H> {
10731073
/// By default this value is not set and corresponds to
10741074
/// `CURLOPT_PROXYPASSWORD`.
10751075
pub fn proxy_password(&mut self, pass: &str) -> Result<(), Error> {
1076-
let pass = try!(CString::new(pass));
1076+
let pass = CString::new(pass)?;
10771077
self.setopt_str(curl_sys::CURLOPT_PROXYPASSWORD, &pass)
10781078
}
10791079

@@ -1119,7 +1119,7 @@ impl<H> Easy2<H> {
11191119
/// By default this option is not set and corresponds to
11201120
/// `CURLOPT_ACCEPT_ENCODING`.
11211121
pub fn accept_encoding(&mut self, encoding: &str) -> Result<(), Error> {
1122-
let encoding = try!(CString::new(encoding));
1122+
let encoding = CString::new(encoding)?;
11231123
self.setopt_str(curl_sys::CURLOPT_ACCEPT_ENCODING, &encoding)
11241124
}
11251125

@@ -1194,7 +1194,7 @@ impl<H> Easy2<H> {
11941194
/// `CURLOPT_COPYPOSTFIELDS`.
11951195
pub fn post_fields_copy(&mut self, data: &[u8]) -> Result<(), Error> {
11961196
// Set the length before the pointer so libcurl knows how much to read
1197-
try!(self.post_field_size(data.len() as u64));
1197+
self.post_field_size(data.len() as u64)?;
11981198
self.setopt_ptr(curl_sys::CURLOPT_COPYPOSTFIELDS, data.as_ptr() as *const _)
11991199
}
12001200

@@ -1209,7 +1209,7 @@ impl<H> Easy2<H> {
12091209
/// `CURLOPT_POSTFIELDSIZE_LARGE`.
12101210
pub fn post_field_size(&mut self, size: u64) -> Result<(), Error> {
12111211
// Clear anything previous to ensure we don't read past a buffer
1212-
try!(self.setopt_ptr(curl_sys::CURLOPT_POSTFIELDS, 0 as *const _));
1212+
self.setopt_ptr(curl_sys::CURLOPT_POSTFIELDS, 0 as *const _)?;
12131213
self.setopt_off_t(
12141214
curl_sys::CURLOPT_POSTFIELDSIZE_LARGE,
12151215
size as curl_sys::curl_off_t,
@@ -1222,7 +1222,7 @@ impl<H> Easy2<H> {
12221222
/// By default this option is set to null and corresponds to
12231223
/// `CURLOPT_HTTPPOST`.
12241224
pub fn httppost(&mut self, form: Form) -> Result<(), Error> {
1225-
try!(self.setopt_ptr(curl_sys::CURLOPT_HTTPPOST, form::raw(&form) as *const _));
1225+
self.setopt_ptr(curl_sys::CURLOPT_HTTPPOST, form::raw(&form) as *const _)?;
12261226
self.inner.form = Some(form);
12271227
Ok(())
12281228
}
@@ -1231,7 +1231,7 @@ impl<H> Easy2<H> {
12311231
///
12321232
/// By default this option is not set and corresponds to `CURLOPT_REFERER`.
12331233
pub fn referer(&mut self, referer: &str) -> Result<(), Error> {
1234-
let referer = try!(CString::new(referer));
1234+
let referer = CString::new(referer)?;
12351235
self.setopt_str(curl_sys::CURLOPT_REFERER, &referer)
12361236
}
12371237

@@ -1240,7 +1240,7 @@ impl<H> Easy2<H> {
12401240
/// By default this option is not set and corresponds to
12411241
/// `CURLOPT_USERAGENT`.
12421242
pub fn useragent(&mut self, useragent: &str) -> Result<(), Error> {
1243-
let useragent = try!(CString::new(useragent));
1243+
let useragent = CString::new(useragent)?;
12441244
self.setopt_str(curl_sys::CURLOPT_USERAGENT, &useragent)
12451245
}
12461246

@@ -1298,7 +1298,7 @@ impl<H> Easy2<H> {
12981298
///
12991299
/// By default this option is not set and corresponds to `CURLOPT_COOKIE`.
13001300
pub fn cookie(&mut self, cookie: &str) -> Result<(), Error> {
1301-
let cookie = try!(CString::new(cookie));
1301+
let cookie = CString::new(cookie)?;
13021302
self.setopt_str(curl_sys::CURLOPT_COOKIE, &cookie)
13031303
}
13041304

@@ -1382,7 +1382,7 @@ impl<H> Easy2<H> {
13821382
///
13831383
/// By default this options corresponds to `CURLOPT_COOKIELIST`
13841384
pub fn cookie_list(&mut self, cookie: &str) -> Result<(), Error> {
1385-
let cookie = try!(CString::new(cookie));
1385+
let cookie = CString::new(cookie)?;
13861386
self.setopt_str(curl_sys::CURLOPT_COOKIELIST, &cookie)
13871387
}
13881388

@@ -1471,7 +1471,7 @@ impl<H> Easy2<H> {
14711471
///
14721472
/// By default this option is not set and corresponds to `CURLOPT_RANGE`.
14731473
pub fn range(&mut self, range: &str) -> Result<(), Error> {
1474-
let range = try!(CString::new(range));
1474+
let range = CString::new(range)?;
14751475
self.setopt_str(curl_sys::CURLOPT_RANGE, &range)
14761476
}
14771477

@@ -1497,7 +1497,7 @@ impl<H> Easy2<H> {
14971497
/// By default this option is not set and corresponds to
14981498
/// `CURLOPT_CUSTOMREQUEST`.
14991499
pub fn custom_request(&mut self, request: &str) -> Result<(), Error> {
1500-
let request = try!(CString::new(request));
1500+
let request = CString::new(request)?;
15011501
self.setopt_str(curl_sys::CURLOPT_CUSTOMREQUEST, &request)
15021502
}
15031503

@@ -1776,7 +1776,7 @@ impl<H> Easy2<H> {
17761776
// /// By default this option is not set and corresponds to
17771777
// /// `CURLOPT_DNS_INTERFACE`.
17781778
// pub fn dns_interface(&mut self, interface: &str) -> Result<(), Error> {
1779-
// let interface = try!(CString::new(interface));
1779+
// let interface = CString::new(interface)?;
17801780
// self.setopt_str(curl_sys::CURLOPT_DNS_INTERFACE, &interface)
17811781
// }
17821782
//
@@ -1789,7 +1789,7 @@ impl<H> Easy2<H> {
17891789
// /// By default this option is not set and corresponds to
17901790
// /// `CURLOPT_DNS_LOCAL_IP4`.
17911791
// pub fn dns_local_ip4(&mut self, ip: &str) -> Result<(), Error> {
1792-
// let ip = try!(CString::new(ip));
1792+
// let ip = CString::new(ip)?;
17931793
// self.setopt_str(curl_sys::CURLOPT_DNS_LOCAL_IP4, &ip)
17941794
// }
17951795
//
@@ -1802,7 +1802,7 @@ impl<H> Easy2<H> {
18021802
// /// By default this option is not set and corresponds to
18031803
// /// `CURLOPT_DNS_LOCAL_IP6`.
18041804
// pub fn dns_local_ip6(&mut self, ip: &str) -> Result<(), Error> {
1805-
// let ip = try!(CString::new(ip));
1805+
// let ip = CString::new(ip)?;
18061806
// self.setopt_str(curl_sys::CURLOPT_DNS_LOCAL_IP6, &ip)
18071807
// }
18081808
//
@@ -1818,7 +1818,7 @@ impl<H> Easy2<H> {
18181818
// /// By default this option is not set and corresponds to
18191819
// /// `CURLOPT_DNS_SERVERS`.
18201820
// pub fn dns_servers(&mut self, servers: &str) -> Result<(), Error> {
1821-
// let servers = try!(CString::new(servers));
1821+
// let servers = CString::new(servers)?;
18221822
// self.setopt_str(curl_sys::CURLOPT_DNS_SERVERS, &servers)
18231823
// }
18241824

@@ -1855,7 +1855,7 @@ impl<H> Easy2<H> {
18551855
/// By default this option is "PEM" and corresponds to
18561856
/// `CURLOPT_SSLCERTTYPE`.
18571857
pub fn ssl_cert_type(&mut self, kind: &str) -> Result<(), Error> {
1858-
let kind = try!(CString::new(kind));
1858+
let kind = CString::new(kind)?;
18591859
self.setopt_str(curl_sys::CURLOPT_SSLCERTTYPE, &kind)
18601860
}
18611861

@@ -1887,7 +1887,7 @@ impl<H> Easy2<H> {
18871887
/// By default this option is "PEM" and corresponds to
18881888
/// `CURLOPT_SSLKEYTYPE`.
18891889
pub fn ssl_key_type(&mut self, kind: &str) -> Result<(), Error> {
1890-
let kind = try!(CString::new(kind));
1890+
let kind = CString::new(kind)?;
18911891
self.setopt_str(curl_sys::CURLOPT_SSLKEYTYPE, &kind)
18921892
}
18931893

@@ -1900,7 +1900,7 @@ impl<H> Easy2<H> {
19001900
/// By default this option is not set and corresponds to
19011901
/// `CURLOPT_KEYPASSWD`.
19021902
pub fn key_password(&mut self, password: &str) -> Result<(), Error> {
1903-
let password = try!(CString::new(password));
1903+
let password = CString::new(password)?;
19041904
self.setopt_str(curl_sys::CURLOPT_KEYPASSWD, &password)
19051905
}
19061906

@@ -1912,7 +1912,7 @@ impl<H> Easy2<H> {
19121912
/// By default this option is not set and corresponds to
19131913
/// `CURLOPT_SSLENGINE`.
19141914
pub fn ssl_engine(&mut self, engine: &str) -> Result<(), Error> {
1915-
let engine = try!(CString::new(engine));
1915+
let engine = CString::new(engine)?;
19161916
self.setopt_str(curl_sys::CURLOPT_SSLENGINE, &engine)
19171917
}
19181918

@@ -2140,7 +2140,7 @@ impl<H> Easy2<H> {
21402140
/// By default this option is not set and corresponds to
21412141
/// `CURLOPT_SSL_CIPHER_LIST`.
21422142
pub fn ssl_cipher_list(&mut self, ciphers: &str) -> Result<(), Error> {
2143-
let ciphers = try!(CString::new(ciphers));
2143+
let ciphers = CString::new(ciphers)?;
21442144
self.setopt_str(curl_sys::CURLOPT_SSL_CIPHER_LIST, &ciphers)
21452145
}
21462146

@@ -2553,7 +2553,7 @@ impl<H> Easy2<H> {
25532553
curl_sys::CURLINFO_COOKIELIST,
25542554
&mut list,
25552555
);
2556-
try!(self.cvt(rc));
2556+
self.cvt(rc)?;
25572557
Ok(list::from_raw(list))
25582558
}
25592559
}
@@ -2770,7 +2770,7 @@ impl<H> Easy2<H> {
27702770
data.len(),
27712771
&mut n,
27722772
);
2773-
try!(self.cvt(rc));
2773+
self.cvt(rc)?;
27742774
Ok(n)
27752775
}
27762776
}
@@ -2783,14 +2783,14 @@ impl<H> Easy2<H> {
27832783
#[cfg(unix)]
27842784
fn setopt_path(&mut self, opt: curl_sys::CURLoption, val: &Path) -> Result<(), Error> {
27852785
use std::os::unix::prelude::*;
2786-
let s = try!(CString::new(val.as_os_str().as_bytes()));
2786+
let s = CString::new(val.as_os_str().as_bytes())?;
27872787
self.setopt_str(opt, &s)
27882788
}
27892789

27902790
#[cfg(windows)]
27912791
fn setopt_path(&mut self, opt: curl_sys::CURLoption, val: &Path) -> Result<(), Error> {
27922792
match val.to_str() {
2793-
Some(s) => self.setopt_str(opt, &try!(CString::new(s))),
2793+
Some(s) => self.setopt_str(opt, &CString::new(s)?),
27942794
None => Err(Error::new(curl_sys::CURLE_CONV_FAILED)),
27952795
}
27962796
}
@@ -2820,7 +2820,7 @@ impl<H> Easy2<H> {
28202820

28212821
fn getopt_bytes(&mut self, opt: curl_sys::CURLINFO) -> Result<Option<&[u8]>, Error> {
28222822
unsafe {
2823-
let p = try!(self.getopt_ptr(opt));
2823+
let p = self.getopt_ptr(opt)?;
28242824
if p.is_null() {
28252825
Ok(None)
28262826
} else {
@@ -2833,7 +2833,7 @@ impl<H> Easy2<H> {
28332833
unsafe {
28342834
let mut p = 0 as *const c_char;
28352835
let rc = curl_sys::curl_easy_getinfo(self.inner.handle, opt, &mut p);
2836-
try!(self.cvt(rc));
2836+
self.cvt(rc)?;
28372837
Ok(p)
28382838
}
28392839
}
@@ -2853,7 +2853,7 @@ impl<H> Easy2<H> {
28532853
unsafe {
28542854
let mut p = 0;
28552855
let rc = curl_sys::curl_easy_getinfo(self.inner.handle, opt, &mut p);
2856-
try!(self.cvt(rc));
2856+
self.cvt(rc)?;
28572857
Ok(p)
28582858
}
28592859
}
@@ -2862,7 +2862,7 @@ impl<H> Easy2<H> {
28622862
unsafe {
28632863
let mut p = 0 as c_double;
28642864
let rc = curl_sys::curl_easy_getinfo(self.inner.handle, opt, &mut p);
2865-
try!(self.cvt(rc));
2865+
self.cvt(rc)?;
28662866
Ok(p)
28672867
}
28682868
}

src/easy/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl List {
3434

3535
/// Appends some data into this list.
3636
pub fn append(&mut self, data: &str) -> Result<(), Error> {
37-
let data = try!(CString::new(data));
37+
let data = CString::new(data)?;
3838
unsafe {
3939
let raw = curl_sys::curl_slist_append(self.raw, data.as_ptr());
4040
assert!(!raw.is_null());

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ extern crate schannel;
6969

7070
use std::ffi::CStr;
7171
use std::str;
72-
use std::sync::{Once, ONCE_INIT};
72+
use std::sync::{Once};
7373

7474
pub use error::{Error, FormError, MultiError, ShareError};
7575
mod error;
@@ -86,7 +86,7 @@ mod panic;
8686
/// It's not required to call this before the library is used, but it's
8787
/// recommended to do so as soon as the program starts.
8888
pub fn init() {
89-
static INIT: Once = ONCE_INIT;
89+
static INIT: Once = Once::new();
9090
INIT.call_once(|| {
9191
platform_init();
9292
unsafe {

0 commit comments

Comments
 (0)