From afa091c46ab02e25e5569244320c55da9a371c92 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 27 Mar 2022 06:56:23 +0200 Subject: [PATCH] Rename `into_array` to `octets`. --- src/addr6.rs | 16 ++++++++++++++++ src/addr8.rs | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/addr6.rs b/src/addr6.rs index 289b9d7..501950c 100644 --- a/src/addr6.rs +++ b/src/addr6.rs @@ -162,9 +162,25 @@ impl MacAddr6 { /// /// assert_eq!(addr.into_array(), [0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67]); /// ``` + #[deprecated(since = "1.1.0", note = "Renamed to `octets` to mirror the standard library's `IpAddr` types.")] pub const fn into_array(self) -> [u8; 6] { self.0 } + + /// Returns the six eight-bit integers the MAC address consists of. + /// + /// ## Example + /// + /// ```rust + /// # use macaddr::MacAddr6; + /// let addr = MacAddr6::new(0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67); + /// + /// assert_eq!(addr.octets(), [0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67]); + /// ``` + #[allow(clippy::trivially_copy_pass_by_ref)] + pub const fn octets(&self) -> [u8; 6] { + self.0 + } } impl FromStr for MacAddr6 { diff --git a/src/addr8.rs b/src/addr8.rs index 9c33d76..56ed505 100644 --- a/src/addr8.rs +++ b/src/addr8.rs @@ -162,9 +162,25 @@ impl MacAddr8 { /// /// assert_eq!(addr.into_array(), [0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67, 0x89, 0xAB]); /// ``` + #[deprecated(since = "1.1.0", note = "Renamed to `octets` to mirror the standard library's `IpAddr` types.")] pub const fn into_array(self) -> [u8; 8] { self.0 } + + /// Returns the eight eight-bit integers the MAC address consists of. + /// + /// ## Example + /// + /// ```rust + /// # use macaddr::MacAddr8; + /// let addr = MacAddr8::new(0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67, 0x89, 0xAB); + /// + /// assert_eq!(addr.octets(), [0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67, 0x89, 0xAB]); + /// ``` + #[allow(clippy::trivially_copy_pass_by_ref)] + pub const fn octets(&self) -> [u8; 8] { + self.0 + } } impl FromStr for MacAddr8 {