// We have to take the conin handle as a usize instead of a *mut c_void in order to avoid a
// lecture from the compiler about how the latter type cannot be safely sent between threads.
// I'm not sure if a better solution exists at this time.
We have to take the conin handle as a usize instead of a *mut c_void in order to avoid a
lecture from the compiler about how the latter type cannot be safely sent between threads.
I'm not sure if a better solution exists at this time.
We have to take the conin handle as a usize instead of a * mut c_void in order to avoid a lecture from the compiler about how the latter type cannot be safely sent between threads . I ' m not sure if a better solution exists at this time .
fn spawn_input_thread(conin: usize) -> Receiver<INPUT_RECORD> {
        let (tx, rx) = mpsc::channel();
        thread::spawn(move || {
            loop {
                let conin = conin as *mut c_void;
                let mut input_record = INPUT_RECORD{EventType: 0 as WORD, Event: [0, 0, 0, 0]};
                let mut events_read: DWORD = 0;
                win32!(ReadConsoleInputW(conin, &mut input_record as PINPUT_RECORD, 1, &mut events_read as LPDWORD));
                if events_read > 0 {
                    tx.send(input_record).unwrap();
                }
            }
        });
        rx
    }
fn spawn_input_thread ( conin : usize ) -> Receiver < INPUT_RECORD > { let ( tx , rx ) = mpsc :: channel ( ) ; thread :: spawn ( move | | { loop { let conin = conin as * mut c_void ; let mut input_record = INPUT_RECORD { EventType : 0 as WORD , Event : [ 0 , 0 , 0 , 0 ] } ; let mut events_read : DWORD = 0 ; win32 ! ( ReadConsoleInputW ( conin mut input_record as PINPUT_RECORD 1 mut events_read as LPDWORD ) ) ; if events_read > 0 { tx . send ( input_record ) . unwrap ( ) ; } } } ) ; rx }
We have to take the conin handle as a usize instead of a *mut c_void in order to avoid a
lecture from the compiler about how the latter type cannot be safely sent between threads.
We have to take the conin handle as a usize instead of a * mut c_void in order to avoid a lecture from the compiler about how the latter type cannot be safely sent between threads .
conin
usize