Rust Declarative Solution
Code\nrust []\nimpl Solution {\n    pub fn shift(row: &mut Vec<i32>, right: bool) {\n        if right {\n            let first = row.remove(0);\n            row
# Code\n```rust []\nimpl Solution {\n    pub fn shift(row: &mut Vec<i32>, right: bool) {\n        if right {\n            let first = row.remove(0);\n            row.push(first)\n        } else {\n            let last = row.pop().unwrap();\n            row.insert(0, last)\n        }\n    } \n\n    pub fn are_similar(mat: Vec<Vec<i32>>, k: i32) -> bool {\n        let mut cur = mat.clone();\n        for _ in 0..k {\n            for row in 0..mat.len() {\n                Solution::shift(&mut cur[row], row % 2 == 0)\n            }\n        }\n        mat == cur\n    }\n}\n```
['Rust']