Address all changes clippy pointed out

This commit is contained in:
Abhishek Chanda
2020-01-18 17:53:15 +00:00
parent ca1d332e71
commit 45fbf458b3
3 changed files with 14 additions and 14 deletions

View File

@ -36,17 +36,17 @@ pub fn cidr_parts(cidr: &str) -> Result<(&str, Option<&str>), IpNetworkError> {
let (ip, prefix) = cidr.split_at(sep);
// Error if cidr has multiple slashes
if prefix[1..].find('/').is_some() {
return Err(IpNetworkError::InvalidCidrFormat(format!(
Err(IpNetworkError::InvalidCidrFormat(format!(
"CIDR must contain a single '/': {}",
cidr
)));
)))
} else {
// Handle the case when cidr has exactly one slash
return Ok((ip, Some(&prefix[1..])));
Ok((ip, Some(&prefix[1..])))
}
} else {
// Handle the case when cidr does not have a slash
return Ok((cidr, None));
Ok((cidr, None))
}
}