How to initialize array with different value without list all of them?

I have an array with first element is 9 and all other element is 0, it's a fixed array so I want make it const.

now it's something like this:
const BASE_DATA: [u8; 64] = [9, 0, 0, .... (repeat 63 times)];

how to initialize it without repeat 0 for 63 times ?

const BASE_DATA: [u8; 64] = {
    let mut arr = [0; 64];
    arr[0] = 9;
    arr
};
4 Likes

thanks !

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.