From 02818488d8417cc874ba4e6977e15cacd1a6e22f Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Wed, 10 Aug 2022 17:41:16 +0200 Subject: [PATCH] Fixed conversion error --- src/ipv4.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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,