From 00508e2485f741e2dca3fc4722d9c63d571975f8 Mon Sep 17 00:00:00 2001 From: meh Date: Thu, 21 May 2015 20:20:16 +0200 Subject: [PATCH] util/error: make it Send and Clone --- src/util/error.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/util/error.rs b/src/util/error.rs index 018ca3f..5d7eef8 100644 --- a/src/util/error.rs +++ b/src/util/error.rs @@ -16,6 +16,29 @@ impl Error { pub fn new(code: c_int) -> Self { Error { code: code, desc: RefCell::new(None) } } + + pub fn bug() -> Self { + Self::new(AVERROR_BUG) + } +} + +unsafe impl Send for Error { } + +impl Clone for Error { + fn clone(&self) -> Self { + if let Some(old) = *self.desc.borrow() { + Error { + code: self.code, + desc: RefCell::new(Some(old)), + } + } + else { + Error { + code: self.code, + desc: RefCell::new(None), + } + } + } } impl From for Error {