Matrix manipulation in Rust