Iterator cycle over array of Colors

Hello, i try to code a square suffering critical hit , and it turns slowly from normal red to dark blood color.

#[macro_use]
extern crate lazy_static;

pub const red255_A: (u8, u8, u8, u8) = (255,0,0,255);
pub const red255_B: (u8, u8, u8, u8) = (230,0,0,255);
pub const red255_C: (u8, u8, u8, u8) = (210,0,0,255);
pub const red255_D: (u8, u8, u8, u8) = (190,0,0,255);
pub const red255_E: (u8, u8, u8, u8) = (170,0,0,255);
pub const red255_F: (u8, u8, u8, u8) = (150,0,0,255);
pub const red255_G: (u8, u8, u8, u8) = (130,0,0,255);
pub const red255_H: (u8, u8, u8, u8) = (100,0,0,255);


lazy_static! {
    static ref RED_A: Color = Color::from(red255_A);
    static ref RED_B: Color = Color::from(red255_B); 
    static ref RED_C: Color = Color::from(red255_C); 
    static ref RED_D: Color = Color::from(red255_D); 
    static ref RED_E: Color = Color::from(red255_E); 
    static ref RED_F: Color = Color::from(red255_F); 
    static ref RED_G: Color = Color::from(red255_G); 
    static ref RED_H: Color = Color::from(red255_H);     

}


pub const REDS_colors: &[Color; 8] = [RED_A,RED_B, RED_C, RED_D, RED_E, RED_F, RED_G, RED_H];

let mut RED_distributor = REDS_colors.iter.cycle();

i get this error:
error[E0308]: mismatched types
--> src/main.rs:55:45
|
55 | pub const REDS_colors: &[Color; 8] = [RED_A,RED_B, RED_C, RED_D, RED_E, RED_F, RED_G, RED_H];
| ^^^^^ expected struct RED_A, found struct RED_B

i work with ggez for my game jam here:

https://itch.io/jam/legion-jam-rustlang

lazy_static creates special "wrapper" values, which ensure the first-access creation of the underlying value. Try dereferencing them, like this:

pub const REDS_colors: &[Color; 8] = [*RED_A, *RED_B, *RED_C, *RED_D, *RED_E, *RED_F, *RED_G, *RED_H];

thank you Cerberuser

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.