fn wrap_last_error<R>(f: impl FnOnce() -> R) -> io::Result<R> {
    unsafe { SetLastError(0) };
    let r = f();
    last_os_error_unless_success()?;
    Ok(r)
}
/// Workaround errata in several console functions:
///
/// *   [`GetConsoleAlias`]
/// *   [`GetConsoleAliases`]
/// *   [`GetConsoleAliasExes`]
///
/// These functions are **mistakenly** documented as returning zero on failure, nonzero (number of bytes read out) on success.
/// However, in the case of an insufficiently large buffer, they return **nonzero** as if succeeding - or more
/// specifically, they return the size of the too-small buffer - without populating the contents of the buffer at all.
///
/// Additionally, merely checking the last set error is insufficient, since these functions will not *clear* the last
/// set error should the function succeed.  As such, this function:
///
/// 1.  Clears the last set error before calling `f()`, such that it can be reliably queried.
/// 2.  Checks the last set error after calling `f()`, regardless of the function's return value.
///
/// Anything other than [`ERROR_SUCCESS`] is converted into an error.
///
/// [`GetConsoleAlias`]:        https://docs.microsoft.com/en-us/windows/console/getconsolealias
/// [`GetConsoleAliases`]:      https://docs.microsoft.com/en-us/windows/console/getconsolealiases
/// [`GetConsoleAliasExes`]:    https://docs.microsoft.com/en-us/windows/console/getconsolealiasexes


These functions are **mistakenly** documented as returning zero on failure, nonzero (number of bytes read out) on success.
However, in the case of an insufficiently large buffer, they return **nonzero** as if succeeding - or more
specifically, they return the size of the too-small buffer - without populating the contents of the buffer at all.

Additionally, merely checking the last set error is insufficient, since these functions will not *clear* the last
set error should the function succeed.  As such, this function.

1.  Clears the last set error before calling `f()`, such that it can be reliably queried.
2.  Checks the last set error after calling `f()`, regardless of the function's return value.

Anything other than [`ERROR_SUCCESS`] is converted into an error.


These functions are ** mistakenly ** documented as returning zero on failure nonzero ( number of bytes read out ) on success . However in the case of an insufficiently large buffer they return ** nonzero ** as if succeeding - or more specifically they return the size of the too - small buffer - without populating the contents of the buffer at all . Additionally merely checking the last set error is insufficient since these functions will not * clear * the last set error should the function succeed . As such this function . 1 . Clears the last set error before calling ` f () ` such that it can be reliably queried . 2 . Checks the last set error after calling ` f () ` regardless of the function ' s return value . Anything other than [ ` ERROR_SUCCESS ` ] is converted into an error .
fn wrap_last_error<R>(f: impl FnOnce() -> R) -> io::Result<R> {
    unsafe { SetLastError(0) };
    let r = f();
    last_os_error_unless_success()?;
    Ok(r)
}
fn wrap_last_error < R > ( f : impl FnOnce ( ) -> R ) -> io :: Result < R > { unsafe { SetLastError ( 0 ) } ; let r = f ( ) ; last_os_error_unless_success ( ) ? ; Ok ( r ) }
Workaround errata in several console functions:
   [`GetConsoleAlias`]
   [`GetConsoleAliases`]
   [`GetConsoleAliasExes`]
Workaround errata in several console functions : [ ` GetConsoleAlias ` ] [ ` GetConsoleAliases ` ] [ ` GetConsoleAliasExes ` ]
f
impl FnOnce() -> R
f
impl FnOnce() -> R