impl Error {
/// Creates a new error from the underlying code returned by libcurl.
pub fn new(code: curl_sys::CURLcode) -> Error {
- Error {
- code: code,
- extra: None,
- }
+ Error { code, extra: None }
}
/// Stores some extra information about this error inside this error.
/// Returns the extra description of this error, if any is available.
pub fn extra_description(&self) -> Option<&str> {
- self.extra.as_ref().map(|s| &**s)
+ self.extra.as_deref()
}
}
impl ShareError {
/// Creates a new error from the underlying code returned by libcurl.
pub fn new(code: curl_sys::CURLSHcode) -> ShareError {
- ShareError { code: code }
+ ShareError { code }
}
/// Returns whether this error corresponds to CURLSHE_BAD_OPTION.
impl MultiError {
/// Creates a new error from the underlying code returned by libcurl.
pub fn new(code: curl_sys::CURLMcode) -> MultiError {
- MultiError { code: code }
+ MultiError { code }
}
/// Returns whether this error corresponds to CURLM_BAD_HANDLE.
impl FormError {
/// Creates a new error from the underlying code returned by libcurl.
pub fn new(code: curl_sys::CURLFORMcode) -> FormError {
- FormError { code: code }
+ FormError { code }
}
/// Returns whether this error corresponds to CURL_FORMADD_MEMORY.