@@ -309,19 +309,19 @@ impl ChannelAdjustmentsBuilder {
309
309
310
310
pub fn build ( & self ) -> ChannelAdjustments {
311
311
let mut adjustments = SlotMap :: with_capacity ( self . adjustments . len ( ) ) ;
312
- let mut led_mappings = Vec :: with_capacity ( self . led_count as _ ) ;
312
+ let mut led_mappings = vec ! [ None ; self . led_count as _] ;
313
313
314
314
for adjustment in & self . adjustments {
315
315
match & adjustment. leds {
316
316
LedMatch :: All => {
317
317
let key = adjustments. insert ( adjustment. data ) ;
318
- led_mappings. fill ( key) ;
318
+ led_mappings. fill ( Some ( key) ) ;
319
319
}
320
320
LedMatch :: Ranges ( ranges) => {
321
321
let key = adjustments. insert ( adjustment. data ) ;
322
322
for range in & ranges. ranges {
323
323
if let Some ( range) = led_mappings. get_mut ( range. clone ( ) ) {
324
- range. fill ( key) ;
324
+ range. fill ( Some ( key) ) ;
325
325
} else {
326
326
error ! ( range = ?range, led_count = %self . led_count, "invalid range" ) ;
327
327
}
@@ -341,7 +341,7 @@ impl ChannelAdjustmentsBuilder {
341
341
#[ derive( Debug , Clone ) ]
342
342
pub struct ChannelAdjustments {
343
343
adjustments : SlotMap < DefaultKey , ColorAdjustmentData > ,
344
- led_mappings : Vec < DefaultKey > ,
344
+ led_mappings : Vec < Option < DefaultKey > > ,
345
345
}
346
346
347
347
impl ChannelAdjustments {
@@ -350,7 +350,8 @@ impl ChannelAdjustments {
350
350
if let Some ( adjustment) = self
351
351
. led_mappings
352
352
. get ( i)
353
- . and_then ( |key| self . adjustments . get ( * key) )
353
+ . and_then ( |key| * key)
354
+ . and_then ( |key| self . adjustments . get ( key) )
354
355
{
355
356
// TODO: Actual 16-bit color?
356
357
* led = color_to16 ( adjustment. apply ( color_to8 ( * led) ) ) ;
0 commit comments