From a4134f6b25605eda8d5557ab5a0d5666f438fa6b Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Sat, 2 Jan 2021 19:57:22 +0000 Subject: [PATCH] net_util: Remove unit error from Result error: this returns a `Result<_, ()> --> net_util/src/mac.rs:68:5 | 68 | pub fn from_bytes(src: &[u8]) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::result-unit-err` implied by `-D warnings` = help: use a custom Error type instead = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_unit_err Replace with std::io::Error like other locations in the same file. Signed-off-by: Rob Bradford --- net_util/src/mac.rs | 7 +++++-- net_util/src/tap.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/net_util/src/mac.rs b/net_util/src/mac.rs index 4a032ffa2..ebf246d6b 100644 --- a/net_util/src/mac.rs +++ b/net_util/src/mac.rs @@ -65,9 +65,12 @@ impl MacAddr { // An error can only occur if the slice length is different from MAC_ADDR_LEN. #[inline] - pub fn from_bytes(src: &[u8]) -> Result { + pub fn from_bytes(src: &[u8]) -> Result { if src.len() != MAC_ADDR_LEN { - return Err(()); + return Err(io::Error::new( + io::ErrorKind::Other, + format!("invalid length of slice: {} vs {}", src.len(), MAC_ADDR_LEN), + )); } Ok(MacAddr::from_bytes_unchecked(src)) } diff --git a/net_util/src/tap.rs b/net_util/src/tap.rs index 69828f4c8..4be620518 100644 --- a/net_util/src/tap.rs +++ b/net_util/src/tap.rs @@ -31,7 +31,7 @@ pub enum Error { NetUtil(NetUtilError), InvalidIfname, /// Error parsing MAC data - MacParsing(()), + MacParsing(IoError), } pub type Result = ::std::result::Result;