pub fn protect<F>(func: F) -> Result<AnyObject, i32>
    where
        F: FnMut() -> AnyObject,
    {
        vm::protect(func)
    }
/// Run a `closure` and protect from panic during raised excpetions
/// by returning `Err<i32>`.
///
/// # Examples
///
/// ```text
/// fn protect_send(&self, method: &str, arguments: &[AnyObject]) -> Result<AnyObject, AnyException> {
///     let closure = || self.send(&method, arguments.as_ref());
///
///     let result = VM::protect(closure);
///
///     result.map_err(|_| {
///         let output = VM::error_info().unwrap();
///
///         // error cleanup
///         VM::clear_error_info();
///
///         output
///     })
/// }
/// ```
Run a `closure` and protect from panic during raised excpetions
by returning `Err`.
Run a ` closure ` and protect from panic during raised excpetions by returning ` Err ` .
pub fn protect<F>(func: F) -> Result<AnyObject, i32>
    where
        F: FnMut() -> AnyObject,
    {
        vm::protect(func)
    }
pub fn protect < F > ( func : F ) -> Result < AnyObject , i32 > where F : FnMut ( ) -> AnyObject , { vm :: protect ( func ) }
Run a `closure` and protect from panic during raised excpetions
by returning `Err<i32>`.
Run a ` closure ` and protect from panic during raised excpetions by returning ` Err<i32 > ` .
func
F
func
F
examples
```text
fn protect_send(&self, method: &str, arguments: &[AnyObject]) -> Result {
let closure = || self.send(&method, arguments.as_ref()).

let result = VM::protect(closure).

result.map_err(|_| {
let output = VM::error_info().unwrap().

error cleanup
VM::clear_error_info().


` ` ` text fn protect_send ( &self method : &str arguments : & [ AnyObject ] ) - > Result { let closure = || self . send ( &method arguments . as_ref () ) . let result = VM :: protect ( closure ) . result . map_err ( |_| { let output = VM :: error_info () . unwrap () . error cleanup VM :: clear_error_info () .