Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 Rust 中获取指向二维数组第一行的指针?以及如何将指针传递给函数,以便可以更改行中的值?
这就是我制作数组的方式:
let state = [mut [mut 0u8, ..4], ..4];
谢谢。
这应该这样做:
fn change_one_row(x: &[mut u8]) { x[0] = 5; } fn main() { let state = [mut [mut 0u8, ..4], ..4]; change_one_row(state[2]); io::println(fmt!("%u", state[2][0] as uint)) }