The following code works as expected and prints Some(192.168.0.0/23) Some(192.168.0.0/24):
#[test]
fn test_spm_vs_lpm() {
let prefix_set = PrefixSet::from_iter(vec![
Ipv4Net::from_str("192.168.0.0/23").unwrap(),
Ipv4Net::from_str("192.168.0.0/24").unwrap(),
]);
let prefix = Ipv4Net::from_str("192.168.0.1/32").unwrap();
println!("{:?} {:?}", prefix_set.get_spm(&prefix), prefix_set.get_lpm(&prefix));
}
However, if we replace the 192.168.0.0/23 with 0.0.0.0/0, the code above will print Some(192.168.0.0/24) Some(192.168.0.0/24) instead of the expected Some(0.0.0.0/0) Some(192.168.0.0/24).
The following code works as expected and prints
Some(192.168.0.0/23) Some(192.168.0.0/24)
:However, if we replace the
192.168.0.0/23
with0.0.0.0/0
, the code above will printSome(192.168.0.0/24) Some(192.168.0.0/24)
instead of the expectedSome(0.0.0.0/0) Some(192.168.0.0/24)
.