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: E
Trait Implementations§
source§impl<E: Ord> Ord for Throw<E>
impl<E: Ord> Ord for Throw<E>
source§impl<E: PartialEq> PartialEq for Throw<E>
impl<E: PartialEq> PartialEq for Throw<E>
source§impl<E: PartialOrd> PartialOrd for Throw<E>
impl<E: PartialOrd> PartialOrd for Throw<E>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<E: Copy> Copy for Throw<E>
impl<E: Eq> Eq for Throw<E>
impl<E> StructuralEq for Throw<E>
impl<E> StructuralPartialEq for Throw<E>
Auto Trait Implementations§
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