/// Run the function and then close any given file descriptors, even if there was an error.
Run the function and then close any given file descriptors, even if there was an error.
Run the function and then close any given file descriptors even if there was an error .
pub fn run_and_close_fds<'a, I, F, U>(fds: I, f: F) -> U
where
    I: IntoIterator<Item = &'a libc::c_int>,
    F: FnOnce() -> U,
{
    let rv = f();
    for fd in fds.into_iter() {
        let rv_close = unsafe { libc::close(*fd) };
        assert_eq!(rv_close, 0, "Could not close fd {}", fd);
    }
    rv
}
pub fn run_and_close_fds < ' a , I , F , U > ( fds : I , f : F ) -> U where I : IntoIterator < Item = & ' a libc :: c_int > , F : FnOnce ( ) -> U , { let rv = f ( ) ; for fd in fds . into_iter ( ) { let rv_close = unsafe { libc :: close ( * fd ) } ; assert_eq ! ( rv_close 0 " " fd ) ; } rv }
Run the function and then close any given file descriptors, even if there was an error.
Run the function and then close any given file descriptors even if there was an error .
fds
I
f
F