fn pin_read_fn_factory(pin: Rc<RefCell<Option<PinKind>>>, pin_num: u16) -> Box<dyn Fn() -> GpioPinValue> {
    Box::from(move || {
        // we drop/unexport the pin in out-mode
        // then it can be an input pin
        PinKind::out_to_in(&pin, pin_num);

        // read value
        let res = {
            // this is a block so that "res" is dropped before we call in_to_out again!

            let mut res = pin.borrow_mut();
            res.as_mut().unwrap().in_pin().read_value().unwrap()
        };

        // we drop/unexport the pin in in-mode
        // then it can be an output pin again
        PinKind::in_to_out(&pin, pin_num);

        return if let GpioValue::High = res { GpioPinValue::HIGH } else { GpioPinValue::LOW }
    })
}
/// Creates a function/closure for the given pin that reads its value in the moment of invocation.
/// It fulfills the contract that the pin will be an out pin after this function is done!
/// Out-Pins are the default for this interface.
Creates a function/closure for the given pin that reads its value in the moment of invocation.
It fulfills the contract that the pin will be an out pin after this function is done.
Out-Pins are the default for this interface.
Creates a function / closure for the given pin that reads its value in the moment of invocation . It fulfills the contract that the pin will be an out pin after this function is done . Out - Pins are the default for this interface .
fn pin_read_fn_factory(pin: Rc<RefCell<Option<PinKind>>>, pin_num: u16) -> Box<dyn Fn() -> GpioPinValue> {
    Box::from(move || {
        // we drop/unexport the pin in out-mode
        // then it can be an input pin
        PinKind::out_to_in(&pin, pin_num);
        // read value
        let res = {
            // this is a block so that "res" is dropped before we call in_to_out again!
            let mut res = pin.borrow_mut();
            res.as_mut().unwrap().in_pin().read_value().unwrap()
        };
        // we drop/unexport the pin in in-mode
        // then it can be an output pin again
        PinKind::in_to_out(&pin, pin_num);
        return if let GpioValue::High = res { GpioPinValue::HIGH } else { GpioPinValue::LOW }
    })
}
fn pin_read_fn_factory ( pin : Rc < RefCell < Option < PinKind > > > , pin_num : u16 ) -> Box < dyn Fn ( ) -> GpioPinValue > { Box :: from ( move | | { // we drop/unexport the pin in out-mode // then it can be an input pin PinKind :: out_to_in ( & pin , pin_num ) ; // read value let res = { // this is a block so that "res" is dropped before we call in_to_out again! let mut res = pin . borrow_mut ( ) ; res . as_mut ( ) . unwrap ( ) . in_pin ( ) . read_value ( ) . unwrap ( ) } ; // we drop/unexport the pin in in-mode // then it can be an output pin again PinKind :: in_to_out ( & pin , pin_num ) ; return if let GpioValue :: High = res { GpioPinValue :: HIGH } else { GpioPinValue :: LOW } } ) }
Creates a function/closure for the given pin that reads its value in the moment of invocation.
Creates a function / closure for the given pin that reads its value in the moment of invocation .
pin
Rc<RefCell<Option<PinKind>>>
pin_num
u16