From 87f5a98a5d8f29d1a631cd06a39863a1e494b4d7 Mon Sep 17 00:00:00 2001
From: Jakub Onderka <ahoj@jakubonderka.cz>
Date: Fri, 18 Jan 2019 19:08:31 +0100
Subject: [PATCH] Use `to_ne_bytes` for converting IPv4Address to octets

It is easier and it should be also faster, because `to_ne_bytes` just calls `mem::transmute`.
---
 src/libstd/net/ip.rs | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs
index f98113e0896f..29f635919cb9 100644
--- a/src/libstd/net/ip.rs
+++ b/src/libstd/net/ip.rs
@@ -393,8 +393,7 @@ impl Ipv4Addr {
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn octets(&self) -> [u8; 4] {
-        let bits = u32::from_be(self.inner.s_addr);
-        [(bits >> 24) as u8, (bits >> 16) as u8, (bits >> 8) as u8, bits as u8]
+        self.inner.s_addr.to_ne_bytes()
     }
 
     /// Returns [`true`] for the special 'unspecified' address (0.0.0.0).