Function windows_helpers::dual_call
source · pub fn dual_call<F, T>(
first_call_expectation: FirstCallExpectation<T>,
call: F
) -> Result<T>Expand description
For functions that are to be called with a preparation step, normally to determine the required buffer size.
You may find that this is easier to verify for correctness than a loop approach - so, less straining on the mind and less time-consuming. It’s also more versatile than a for approach.
The closure parameter will be true for the first call. It can be called something like getting_buffer_size.
If the expectation after the first call isn’t met and it returned an Err, the function ends with that Err. If the first call returned Ok, however, and this didn’t harmonize with the expectation, Err including HRESULT E_UNEXPECTED is returned.