Function windows_helpers::dual_call

source ·
pub fn dual_call<F, T>(
    first_call_expectation: FirstCallExpectation<T>,
    call: F
) -> Result<T>
where F: FnMut(bool) -> Result<T>, T: PartialEq,
Expand description

For functions that are to be called with a preparation step, normally to determine the required buffer size. Easier to verify for correctness by the developer than a loop approach - so, less straining on the mind and less time-consuming. More versatile than a for approach.

The closure parameter will be true for the first call.

If the expectation after the first call isn’t met, the Err from the closure is returned. Returns Err incl. [HRESULT] E_UNEXPECTED, however, if the first call returned Ok and this didn’t harmonize with the expectation.