pub struct Throw<E>(pub E);Expand description
A wrapper type for throwing lua errors from a rust callback’s result.
§Example
use tlua::{Function, Lua, Throw};
fn may_fail() -> Result<String, String> {
Err("failed".into())
}
let lua = Lua::new();
lua.set("callback", Function::new(|| -> Result<String, Throw<String>> {
let foo = may_fail()?;
Ok(format!("bar{}", foo))
}));
assert!(lua.exec("callback()").is_err())Tuple Fields§
§0: ETrait Implementations§
Source§impl<E: Ord> Ord for Throw<E>
impl<E: Ord> Ord for Throw<E>
Source§impl<E: PartialOrd> PartialOrd for Throw<E>
impl<E: PartialOrd> PartialOrd for Throw<E>
impl<E: Copy> Copy for Throw<E>
impl<E: Eq> Eq for Throw<E>
impl<E> StructuralPartialEq for Throw<E>
Auto Trait Implementations§
impl<E> Freeze for Throw<E>where
E: Freeze,
impl<E> RefUnwindSafe for Throw<E>where
E: RefUnwindSafe,
impl<E> Send for Throw<E>where
E: Send,
impl<E> Sync for Throw<E>where
E: Sync,
impl<E> Unpin for Throw<E>where
E: Unpin,
impl<E> UnwindSafe for Throw<E>where
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more