Rust是否具有以下类型定义?
typedef int32_t fe[10];
typedef struct {
fe X;
fe Y;
fe Z;
fe T;
} ge_p3;
我知道如何在Rust中定义ge_p3
,但我不知道如何定义fe
:
type ge_p3 {
X:fe, Y:fe, Z: fe, T: fe
}
答案 0 :(得分:4)
尝试this:
fn main() {
let a: Int32Array = [1; 10];
println!("{:?}", a);
let g: GeP3 = GeP3 {
x: a,
..Default::default()
};
println!("{:?}", g);
}
type Int32Array = [i32; 10];
#[derive(Default, Debug)]
struct GeP3 {
x: Int32Array,
y: Int32Array,
z: Int32Array,
t: Int32Array,
}
输出:
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
GeP3 { x: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], y: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], z: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], t: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }