Function std::rt::unwind::try[src]
pub unsafe fn try(f: ||) -> Result<(), Box<Any>>
Invoke a closure, capturing the cause of failure if one occurs.
This function will return None if the closure did not fail, and will
return Some(cause) if the closure fails. The cause returned is the
object with which failure was originally invoked.
This function also is unsafe for a variety of reasons:
This is not safe to call in a nested fashion. The unwinding interface for Rust is designed to have at most one try/catch block per task, not multiple. No runtime checking is currently performed to uphold this invariant, so this function is not safe. A nested try/catch block may result in corruption of the outer try/catch block's state, especially if this is used within a task itself.
It is not sound to trigger unwinding while already unwinding. Rust tasks have runtime checks in place to ensure this invariant, but it is not guaranteed that a rust task is in place when invoking this function. Unwinding twice can lead to resource leaks where some destructors are not run.