mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
fix: implement Display instead of ToString
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use argh::FromArgs;
|
use argh::FromArgs;
|
||||||
@@ -86,15 +87,16 @@ impl FromStr for LedBrightness {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for LedBrightness {
|
impl fmt::Display for LedBrightness {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self.level {
|
let s = match self.level {
|
||||||
Some(0x00) => "off".to_owned(),
|
Some(0x00) => "off",
|
||||||
Some(0x01) => "low".to_owned(),
|
Some(0x01) => "low",
|
||||||
Some(0x02) => "med".to_owned(),
|
Some(0x02) => "med",
|
||||||
Some(0x03) => "high".to_owned(),
|
Some(0x03) => "high",
|
||||||
_ => "unknown".to_owned(),
|
_ => "unknown",
|
||||||
}
|
};
|
||||||
|
write!(f, "{}", s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user