objc 0.1.8

Objective-C Runtime bindings and wrapper for Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use objc_exception;

use id::StrongPtr;
use runtime::Object;

pub unsafe fn try<F, R>(closure: F) -> Result<R, Option<StrongPtr>>
        where F: FnOnce() -> R {
    objc_exception::try(closure).map_err(|exception| {
        if exception.is_null() { None }
        else { Some(StrongPtr::new(exception as *mut Object)) }
    })
}