Count Items Matching a Rule LeetCode solution in Rust
1impl Solution {2pub fn count_matches(items: Vec<Vec<String>>, rule_key: String, rule_value: String) -> i32 {3let mut ans = 0;45for item in items.iter() {6match rule_key.as_str() {7"type" => {8if (item[0] == rule_value) {9ans += 110}11}12"color" => {13if (item[1] == rule_value) {14ans += 115}16}17"name" => {18if (item[2] == rule_value) {19ans += 120}21}22_ => (),23}24}2526ans27}28}