Function mentat_ffi::utils::error::translate_opt_result
[−]
[src]
pub unsafe fn translate_opt_result<T, E>(
result: Result<Option<T>, E>,
error: *mut ExternError
) -> *mut T where
E: Display,
Translate Result<Option#[repr(C)]
.
- If
result
isOk(Some(v))
, movesv
to the heap and returns a pointer to it, and setserror
to a state indicating that no error occurred (message
is null). - If
result
isOk(None)
returns a null pointer, but setserror
to a state indicating that no error occurred (message
is null). - If
result
isErr(e)
, returns a null pointer and stores a string representing the error message (which was allocated on the heap and should eventually be freed) intoerror.message