如何为具有固定大小的char数组创建类型别名?

アレッ*_*ックス 2 arrays rust

我无法弄清楚如何创建一个类型,以便:

type CountryCode = &[char] // only 3 chars in it, no more
Run Code Online (Sandbox Code Playgroud)

是否可以使用type,或者我应该使用struct

She*_*ter 5

使用示例代码扩展@Levans的注释:

type CountryCode = [char; 3];

fn print_it(code: CountryCode) {
    println!("{:?}", code);
}

fn main() {
    let code: CountryCode = ['u', 's', 'a'];
    print_it(code);
}
Run Code Online (Sandbox Code Playgroud)