Skip to content

Commit 2d383d4

Browse files
committed
Implements std::error::Error for ErrCode.
This change supports "Error interoperation". See rust-lang/rfcs#201, rust-lang/rust#17747.
1 parent 7e6355a commit 2d383d4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ffi/err.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::c_str::CString;
2-
use std::fmt;
2+
use std::{error, fmt, str};
33
use libc::{c_int,c_char};
44

55
#[allow(non_camel_case_types)]
@@ -148,3 +148,9 @@ impl fmt::Show for ErrCode {
148148
}
149149
}
150150
}
151+
152+
impl error::Error for ErrCode {
153+
fn description(&self) -> &str {
154+
unsafe { str::raw::c_str_to_static_slice(curl_easy_strerror(*self)) }
155+
}
156+
}

0 commit comments

Comments
 (0)