Есть типа такой код:
fn run_input_device(dev: &str) {
let input = MidiInput::new("Some input").unwrap();
let ports = input.ports();
let mut port = Option::None;
for i in &ports {
if input.port_name(&i).unwrap() == dev {
port = Some(i);
}
};
let callback = move |stamp: u64, message: &[u8], _| {
// println!("{}: {:?} (len = {})", stamp, message, message.len());}, ());
let st = format!("{}: {:?} (len = {}\n", stamp, message, message.len());
std::io::stdout().write_all(st.as_bytes()).unwrap();
std::io::stdout().flush().unwrap();
};
if port.is_some() {
let conn = input.connect(port.unwrap(), "midir-read-input", callback, ());
loop {}
}
}
Компилятор чихает следующим:
|
116 | let conn = input.connect(port.unwrap(), "midir-read-input", callback, ());
| ^^^^^^^ one type is more general than the other
|
= note: expected type `FnOnce<(u64, &[u8], &mut ())>`
found type `for<'r> FnOnce<(u64, &'r [u8], &mut ())>`
error: aborting due to previous error