Skip to content

Commit d96db40

Browse files
committed
Rename into_array to octets.
1 parent 4c2305a commit d96db40

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/addr6.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,25 @@ impl MacAddr6 {
162162
///
163163
/// assert_eq!(addr.into_array(), [0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67]);
164164
/// ```
165+
#[deprecated(since = "1.1.0", note = "Renamed to `octets` to mirror the standard library's `IpAddr` types.")]
165166
pub const fn into_array(self) -> [u8; 6] {
166167
self.0
167168
}
169+
170+
/// Returns the six eight-bit integers the MAC address consists of.
171+
///
172+
/// ## Example
173+
///
174+
/// ```rust
175+
/// # use macaddr::MacAddr6;
176+
/// let addr = MacAddr6::new(0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67);
177+
///
178+
/// assert_eq!(addr.octets(), [0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67]);
179+
/// ```
180+
#[allow(clippy::trivially_copy_pass_by_ref)]
181+
pub const fn octets(&self) -> [u8; 6] {
182+
*self.0
183+
}
168184
}
169185

170186
impl FromStr for MacAddr6 {

src/addr8.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,25 @@ impl MacAddr8 {
162162
///
163163
/// assert_eq!(addr.into_array(), [0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67, 0x89, 0xAB]);
164164
/// ```
165+
#[deprecated(since = "1.1.0", note = "Renamed to `octets` to mirror the standard library's `IpAddr` types.")]
165166
pub const fn into_array(self) -> [u8; 8] {
166167
self.0
167168
}
169+
170+
/// Returns the eight eight-bit integers the MAC address consists of.
171+
///
172+
/// ## Example
173+
///
174+
/// ```rust
175+
/// # use macaddr::MacAddr8;
176+
/// let addr = MacAddr8::new(0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67, 0x89, 0xAB);
177+
///
178+
/// assert_eq!(addr.octets(), [0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67, 0x89, 0xAB]);
179+
/// ```
180+
#[allow(clippy::trivially_copy_pass_by_ref)]
181+
pub const fn octets(&self) -> [u8; 8] {
182+
*self.0
183+
}
168184
}
169185

170186
impl FromStr for MacAddr8 {

0 commit comments

Comments
 (0)