Skip to content

Commit

Permalink
Merge pull request #5 from ttytm/refactor/example
Browse files Browse the repository at this point in the history
Reduce unnecessary nesting in example
  • Loading branch information
haimgel authored Nov 5, 2024
2 parents 9677289 + 0d5b854 commit 958f4ad
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions examples/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ fn main() {

if monitors.is_empty() {
println!("No external monitors found");
} else {
for mut monitor in monitors {
println!("Monitor");
println!("\tDescription: {}", monitor.description());
if let Some(desc) = monitor.product_name() {
println!("\tProduct Name: {}", desc);
}
if let Some(number) = monitor.serial_number() {
println!("\tSerial Number: {}", number);
}
if let Ok(input) = monitor.get_vcp_feature(0x60) {
println!("\tCurrent input: {:04x}", input.value());
}
return;
}

if let Some(data) = monitor.edid() {
let mut cursor = std::io::Cursor::new(&data);
let mut reader = edid_rs::Reader::new(&mut cursor);
match edid_rs::EDID::parse(&mut reader) {
Ok(edid) => println!("\tEDID Info: {:?}", edid),
_ => println!("\tCould not parse provided EDID information"),
}
for mut monitor in monitors {
println!("Monitor");
println!("\tDescription: {}", monitor.description());
if let Some(desc) = monitor.product_name() {
println!("\tProduct Name: {}", desc);
}
if let Some(number) = monitor.serial_number() {
println!("\tSerial Number: {}", number);
}
if let Ok(input) = monitor.get_vcp_feature(0x60) {
println!("\tCurrent input: {:04x}", input.value());
}
if let Some(data) = monitor.edid() {
let mut cursor = std::io::Cursor::new(&data);
let mut reader = edid_rs::Reader::new(&mut cursor);
match edid_rs::EDID::parse(&mut reader) {
Ok(edid) => println!("\tEDID Info: {:?}", edid),
_ => println!("\tCould not parse provided EDID information"),
}
}
}
Expand Down

0 comments on commit 958f4ad

Please sign in to comment.