Remove dead code
This commit is contained in:
parent
1619222fb3
commit
46625984f3
49
src/pcd.rs
49
src/pcd.rs
@ -471,55 +471,6 @@ impl RoleDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn compare_maps(map1: &Map<String, Value>, map2: &Map<String, Value>) -> bool {
|
||||
// First, check if both maps have the same keys
|
||||
if map1.keys().collect::<Vec<&String>>() != map2.keys().collect::<Vec<&String>>() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Then, check if the corresponding values have the same type
|
||||
for key in map1.keys() {
|
||||
let value1 = map1.get(key).unwrap();
|
||||
let value2 = map2.get(key).unwrap();
|
||||
|
||||
if !compare_values(value1, value2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
fn compare_values(value1: &Value, value2: &Value) -> bool {
|
||||
if value1.is_null() && value2.is_null() {
|
||||
return true;
|
||||
} else if value1.is_boolean() && value2.is_boolean() {
|
||||
return true;
|
||||
} else if value1.is_number() && value2.is_number() {
|
||||
return true;
|
||||
} else if value1.is_string() && value2.is_string() {
|
||||
return true;
|
||||
} else if value1.is_array() && value2.is_array() {
|
||||
return compare_arrays(value1.as_array().unwrap(), value2.as_array().unwrap());
|
||||
} else if value1.is_object() && value2.is_object() {
|
||||
// Recursive comparison for nested objects
|
||||
return compare_maps(value1.as_object().unwrap(), value2.as_object().unwrap());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fn compare_arrays(array1: &Vec<Value>, array2: &Vec<Value>) -> bool {
|
||||
// Compare the type of each element in the arrays
|
||||
for (elem1, elem2) in array1.iter().zip(array2.iter()) {
|
||||
if !compare_values(elem1, elem2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user