pub fn from_result<T, F>(f: F) -> TExpand description
Calls a closure returning a crate::error::Result<T> and converts the result to
a C integer result.
This is useful when calling Rust functions that return crate::error::Result<T>
from inside extern "C" functions that need to return an integer error result.
T should be convertible from an i16 via From<i16>.
§Examples
ⓘ
unsafe extern "C" fn probe_callback(
pdev: *mut bindings::platform_device,
) -> kernel::ffi::c_int {
from_result(|| {
let ptr = devm_alloc(pdev)?;
bindings::platform_set_drvdata(pdev, ptr);
Ok(0)
})
}