From 2d383d48b7f728f4bff732e2f017cacf0e914ba8 Mon Sep 17 00:00:00 2001 From: gifnksm Date: Mon, 3 Nov 2014 20:03:15 +0900 Subject: [PATCH] Implements `std::error::Error` for `ErrCode`. This change supports "Error interoperation". See rust-lang/rfcs#201, rust-lang/rust#17747. --- src/ffi/err.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ffi/err.rs b/src/ffi/err.rs index 2a2caba879..cef0913b12 100644 --- a/src/ffi/err.rs +++ b/src/ffi/err.rs @@ -1,5 +1,5 @@ use std::c_str::CString; -use std::fmt; +use std::{error, fmt, str}; use libc::{c_int,c_char}; #[allow(non_camel_case_types)] @@ -148,3 +148,9 @@ impl fmt::Show for ErrCode { } } } + +impl error::Error for ErrCode { + fn description(&self) -> &str { + unsafe { str::raw::c_str_to_static_slice(curl_easy_strerror(*self)) } + } +}