Utilize if..else for switching on boolean values.

This commit is contained in:
Corey Farwell 2018-06-24 10:27:46 -04:00
parent 94880b2db7
commit 59d4505749

View File

@ -105,9 +105,10 @@ pub extern "C" fn protocol_list_supports_protocol(
Ok(n) => n.into(), Ok(n) => n.into(),
Err(_) => return 0, Err(_) => return 0,
}; };
match proto_entry.supports_protocol(&protocol, &version) { if proto_entry.supports_protocol(&protocol, &version) {
false => return 0, 1
true => return 1, } else {
0
} }
} }
@ -206,13 +207,16 @@ pub extern "C" fn protover_compute_vote(
let mut proto_entries: Vec<UnvalidatedProtoEntry> = Vec::new(); let mut proto_entries: Vec<UnvalidatedProtoEntry> = Vec::new();
for datum in data { for datum in data {
let entry: UnvalidatedProtoEntry = match allow_long_proto_names { let entry: UnvalidatedProtoEntry = if allow_long_proto_names {
true => match UnvalidatedProtoEntry::from_str_any_len(datum.as_str()) { match UnvalidatedProtoEntry::from_str_any_len(datum.as_str()) {
Ok(n) => n, Ok(n) => n,
Err(_) => continue}, Err(_) => continue
false => match datum.parse() { }
} else {
match datum.parse() {
Ok(n) => n, Ok(n) => n,
Err(_) => continue}, Err(_) => continue
}
}; };
proto_entries.push(entry); proto_entries.push(entry);
} }