Add dyn to trait objects
This commit is contained in:
parent
47a8ac2b05
commit
14a68dd6d2
|
@ -183,7 +183,7 @@ impl fmt::Display for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl failure::Fail for Error {
|
impl failure::Fail for Error {
|
||||||
fn cause(&self) -> Option<&failure::Fail> {
|
fn cause(&self) -> Option<&dyn failure::Fail> {
|
||||||
match *self {
|
match *self {
|
||||||
Error::CallbackError { ref cause, .. } => Some(cause.as_ref()),
|
Error::CallbackError { ref cause, .. } => Some(cause.as_ref()),
|
||||||
Error::ExternalError(ref err) => err.as_fail().cause(),
|
Error::ExternalError(ref err) => err.as_fail().cause(),
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub type Number = ffi::lua_Number;
|
||||||
pub struct LightUserData(pub *mut c_void);
|
pub struct LightUserData(pub *mut c_void);
|
||||||
|
|
||||||
pub(crate) type Callback<'lua, 'a> =
|
pub(crate) type Callback<'lua, 'a> =
|
||||||
Box<Fn(&'lua Lua, MultiValue<'lua>) -> Result<MultiValue<'lua>> + 'a>;
|
Box<dyn Fn(&'lua Lua, MultiValue<'lua>) -> Result<MultiValue<'lua>> + 'a>;
|
||||||
|
|
||||||
/// An auto generated key into the Lua registry.
|
/// An auto generated key into the Lua registry.
|
||||||
///
|
///
|
||||||
|
|
|
@ -661,11 +661,11 @@ pub unsafe fn init_error_metatables(state: *mut ffi::lua_State) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct WrappedError(pub Error);
|
struct WrappedError(pub Error);
|
||||||
struct WrappedPanic(pub Option<Box<Any + Send>>);
|
struct WrappedPanic(pub Option<Box<dyn Any + Send>>);
|
||||||
|
|
||||||
// Pushes a WrappedError::Panic to the top of the stack. Uses two stack spaces and does not call
|
// Pushes a WrappedError::Panic to the top of the stack. Uses two stack spaces and does not call
|
||||||
// lua_checkstack.
|
// lua_checkstack.
|
||||||
unsafe fn push_wrapped_panic(state: *mut ffi::lua_State, panic: Box<Any + Send>) {
|
unsafe fn push_wrapped_panic(state: *mut ffi::lua_State, panic: Box<dyn Any + Send>) {
|
||||||
gc_guard(state, || {
|
gc_guard(state, || {
|
||||||
let ud = ffi::lua_newuserdata(state, mem::size_of::<WrappedPanic>()) as *mut WrappedPanic;
|
let ud = ffi::lua_newuserdata(state, mem::size_of::<WrappedPanic>()) as *mut WrappedPanic;
|
||||||
ptr::write(ud, WrappedPanic(Some(panic)))
|
ptr::write(ud, WrappedPanic(Some(panic)))
|
||||||
|
|
Loading…
Reference in New Issue