Loading RustViz Engine...
Validate IPv4 address string into a 4-byte array [u8; 4].
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
pub fn parse_ipv4(ip: &str) -> Option<[u8; 4]> {
let parts: Vec<&str> = ip.split('.').collect();
if parts.len() != 4 { return None; }
let mut octets = [0u8; 4];
for (i, part) in parts.iter().enumerate() {
octets[i] = part.parse::<u8>().ok()?;
}
Some(octets)
}