diff --git a/src/ipv4.rs b/src/ipv4.rs index aaff5d4..c3755ae 100644 --- a/src/ipv4.rs +++ b/src/ipv4.rs @@ -1,5 +1,5 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr}; - +use std::convert::TryInto; use crate::util; use anyhow::{anyhow, Result}; use convert_base::Convert; @@ -37,6 +37,9 @@ impl IPv4 { // Reverse it so that we start from the top ip = ip.into_iter().rev().collect(); + // convert to array + let ip: [u8; 4] = ip.try_into().unwrap_or_else(|v: Vec| panic!("Unable to convert Vec to [u8; 4] for IPv4!")); + Self { id, ip,