From c53a9e27ae5db272ef2c46bbcfbd64b32ae78a19 Mon Sep 17 00:00:00 2001 From: Victoria Fischer Date: Sat, 16 Nov 2024 16:25:32 +0100 Subject: [PATCH] power: implement asmilliwatts for sized arrays --- src/power.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/power.rs b/src/power.rs index e98f762..9b59679 100644 --- a/src/power.rs +++ b/src/power.rs @@ -25,6 +25,13 @@ impl AsMilliwatts for [T] where T: AsMilliwatts { } } + +impl AsMilliwatts for [T; S] where T: AsMilliwatts { + fn as_milliwatts(&self) -> u32 { + self.iter().map(|p| { p.as_milliwatts() }).sum() + } +} + pub fn brightness_for_mw(total_mw : u32, target : u8, max_power: u32) -> u8 { let target32 = target as u32; let requested_mw = (total_mw * target32) / 256;