about summary refs log tree commit diff
path: root/src/libstd/net/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/net/mod.rs')
-rw-r--r--src/libstd/net/mod.rs19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/libstd/net/mod.rs b/src/libstd/net/mod.rs
index b68146939fd..8652ed8b046 100644
--- a/src/libstd/net/mod.rs
+++ b/src/libstd/net/mod.rs
@@ -85,21 +85,10 @@ pub enum Shutdown {
     Both,
 }
 
-#[doc(hidden)]
-trait NetInt {
-    fn from_be(i: Self) -> Self;
-    fn to_be(&self) -> Self;
-}
-macro_rules! doit {
-    ($($t:ident)*) => ($(impl NetInt for $t {
-        fn from_be(i: Self) -> Self { <$t>::from_be(i) }
-        fn to_be(&self) -> Self { <$t>::to_be(*self) }
-    })*)
-}
-doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
-
-fn hton<I: NetInt>(i: I) -> I { i.to_be() }
-fn ntoh<I: NetInt>(i: I) -> I { I::from_be(i) }
+#[inline]
+const fn htons(i: u16) -> u16 { i.to_be() }
+#[inline]
+const fn ntohs(i: u16) -> u16 { u16::from_be(i) }
 
 fn each_addr<A: ToSocketAddrs, F, T>(addr: A, mut f: F) -> io::Result<T>
     where F: FnMut(io::Result<&SocketAddr>) -> io::Result<T>