Fixup Display output to unwrap name

This commit is contained in:
Jeff Hiner 2021-02-24 09:54:55 -07:00
parent a55f319854
commit 7da53b57fe
2 changed files with 2 additions and 2 deletions

View file

@ -9,7 +9,7 @@ fn main() {
} else { } else {
let mut devices = evdev::enumerate().collect::<Vec<_>>(); let mut devices = evdev::enumerate().collect::<Vec<_>>();
for (i, d) in devices.iter().enumerate() { for (i, d) in devices.iter().enumerate() {
println!("{}: {:?}", i, d.name()); println!("{}: {}", i, d.name().unwrap_or("Unnamed device"));
} }
print!("Select the device [0-{}]: ", devices.len()); print!("Select the device [0-{}]: ", devices.len());
let _ = std::io::stdout().flush(); let _ = std::io::stdout().flush();

View file

@ -222,7 +222,7 @@ const fn bus_name(x: u16) -> &'static str {
impl std::fmt::Display for Device { impl std::fmt::Display for Device {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
writeln!(f, "{:?}", self.name)?; writeln!(f, "{}", self.name.as_deref().unwrap_or("Unnamed device"))?;
writeln!( writeln!(
f, f,
" Driver version: {}.{}.{}", " Driver version: {}.{}.{}",