pub fn match_result_code_optional<F, T>(
result_code: i32,
on_success: F,
) -> Result<Option<T>>Expand description
Evaluates a result code and executes a closure on success, handling optional return values.
This function is similar to match_result_code but is designed to work with closures
that return Option<T> values, making it suitable for operations that may legitimately
return no data even on success.
§Arguments
result_code- An integer representing the operation result codeon_success- A closure that will be executed if result_code >= 0, returningOption<T>
§Type Parameters
F- The type of the closure that returnsOption<T>T- The inner type of the optional value returned by the closure
§Returns
Returns a Result<Option<T>> where:
Ok(Some(T))- Contains the value returned by the closure if result_code >= 0 and closure returns SomeOk(None)- If result_code >= 0 but the closure returns NoneErr(Error)- For negative result codes
§Note
This function treats all non-negative result codes as success, allowing the closure to determine whether data is present through its Option return type.