From a23b2e8e9472e5c8a5553609bc8fb07bc3ff5231 Mon Sep 17 00:00:00 2001 From: Victoria Fischer Date: Thu, 14 Nov 2024 19:43:14 +0100 Subject: [PATCH] power: implement AsMilliwatts for slices --- src/power.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/power.rs b/src/power.rs index c7524a7..e98f762 100644 --- a/src/power.rs +++ b/src/power.rs @@ -19,6 +19,12 @@ impl AsMilliwatts for RGB8 { } } +impl AsMilliwatts for [T] 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;