diff --git a/src/card.rs b/src/card.rs index 6383d27..8fdb31f 100644 --- a/src/card.rs +++ b/src/card.rs @@ -56,4 +56,4 @@ impl Debug for Card { } } -impl ControlDevice for Card {} \ No newline at end of file +impl ControlDevice for Card {} diff --git a/src/main.rs b/src/main.rs index b2a5105..5d6aa56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,10 +27,7 @@ fn main() { let encoder_info = match current_encoder { Some(encoder) => { - let crtc_info = encoder.crtc() - .and_then(|crtc_handle| gpu.get_crtc(crtc_handle).ok()) - .and_then(|crtc| Some(format!("{:?}", crtc))) - .unwrap_or_else(|| format!("No CRTC data")); + let crtc_info = format_crtc(&gpu, encoder.crtc()); format!("{:?}, {}", encoder.kind(), crtc_info) } @@ -38,10 +35,17 @@ fn main() { }; println!("\t\tEncoder: {}", encoder_info); - + println!(""); // Add blank line }, Err(_) => {} } } -} \ No newline at end of file +} + +fn format_crtc(gpu: &card::Card, crtc_handle: Option) -> String { + match crtc_handle.and_then(|handle| Some(gpu.get_crtc(handle))) { + Some(crtc) => format!("{:?}", crtc), + None => format!("No CRTC data") + } +}