about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew McPherrin <matt@mcpherrin.ca>2014-03-16 15:31:47 -0700
committerMatthew McPherrin <matt@mcpherrin.ca>2014-03-16 15:57:16 -0700
commit5026d114a0bbe27f2052af9fbadebacac80e1955 (patch)
treee599c627cf5d9d3fad12129c30951131e2f272c1
parent7156ded5bcf6831a6da22688d08f71985fdc81df (diff)
downloadrust-5026d114a0bbe27f2052af9fbadebacac80e1955.tar.gz
rust-5026d114a0bbe27f2052af9fbadebacac80e1955.zip
Doc-sprint: Document endian conversion functions
-rw-r--r--src/libstd/mem.rs95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/libstd/mem.rs b/src/libstd/mem.rs
index 603f2b80eea..e124ada08c7 100644
--- a/src/libstd/mem.rs
+++ b/src/libstd/mem.rs
@@ -99,32 +99,127 @@ pub unsafe fn move_val_init<T>(dst: &mut T, src: T) {
     intrinsics::move_val_init(dst, src)
 }
 
+/// Convert an i16 to little endian from the target's endianness.
+///
+/// On little endian, this is a no-op.  On big endian, the bytes are swapped.
 #[cfg(target_endian = "little")] #[inline] pub fn to_le16(x: i16) -> i16 { x }
+
+/// Convert an i16 to little endian from the target's endianness.
+///
+/// On little endian, this is a no-op.  On big endian, the bytes are swapped.
 #[cfg(target_endian = "big")]    #[inline] pub fn to_le16(x: i16) -> i16 { unsafe { bswap16(x) } }
+
+/// Convert an i32 to little endian from the target's endianness.
+///
+/// On little endian, this is a no-op.  On big endian, the bytes are swapped.
 #[cfg(target_endian = "little")] #[inline] pub fn to_le32(x: i32) -> i32 { x }
+
+/// Convert an i32 to little endian from the target's endianness.
+///
+/// On little endian, this is a no-op.  On big endian, the bytes are swapped.
 #[cfg(target_endian = "big")]    #[inline] pub fn to_le32(x: i32) -> i32 { unsafe { bswap32(x) } }
+
+/// Convert an i64 to little endian from the target's endianness.
+///
+/// On little endian, this is a no-op.  On big endian, the bytes are swapped.
 #[cfg(target_endian = "little")] #[inline] pub fn to_le64(x: i64) -> i64 { x }
+
+/// Convert an i64 to little endian from the target's endianness.
+///
+/// On little endian, this is a no-op.  On big endian, the bytes are swapped.
 #[cfg(target_endian = "big")]    #[inline] pub fn to_le64(x: i64) -> i64 { unsafe { bswap64(x) } }
 
+
+/// Convert an i16 to big endian from the target's endianness.
+///
+/// On big endian, this is a no-op.  On little endian, the bytes are swapped.
 #[cfg(target_endian = "little")] #[inline] pub fn to_be16(x: i16) -> i16 { unsafe { bswap16(x) } }
+
+/// Convert an i16 to big endian from the target's endianness.
+///
+/// On big endian, this is a no-op.  On little endian, the bytes are swapped.
 #[cfg(target_endian = "big")]    #[inline] pub fn to_be16(x: i16) -> i16 { x }
+
+/// Convert an i32 to big endian from the target's endianness.
+///
+/// On big endian, this is a no-op.  On little endian, the bytes are swapped.
 #[cfg(target_endian = "little")] #[inline] pub fn to_be32(x: i32) -> i32 { unsafe { bswap32(x) } }
+
+/// Convert an i32 to big endian from the target's endianness.
+///
+/// On big endian, this is a no-op.  On little endian, the bytes are swapped.
 #[cfg(target_endian = "big")]    #[inline] pub fn to_be32(x: i32) -> i32 { x }
+
+/// Convert an i64 to big endian from the target's endianness.
+///
+/// On big endian, this is a no-op.  On little endian, the bytes are swapped.
 #[cfg(target_endian = "little")] #[inline] pub fn to_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
+
+/// Convert an i64 to big endian from the target's endianness.
+///
+/// On big endian, this is a no-op.  On little endian, the bytes are swapped.
 #[cfg(target_endian = "big")]    #[inline] pub fn to_be64(x: i64) -> i64 { x }
 
+
+/// Convert an i16 from little endian to the target's endianness.
+///
+/// On little endian, this is a no-op.  On big endian, the bytes are swapped.
 #[cfg(target_endian = "little")] #[inline] pub fn from_le16(x: i16) -> i16 { x }
+
+/// Convert an i16 from little endian to the target's endianness.
+///
+/// On little endian, this is a no-op.  On big endian, the bytes are swapped.
 #[cfg(target_endian = "big")]    #[inline] pub fn from_le16(x: i16) -> i16 { unsafe { bswap16(x) } }
+
+/// Convert an i32 from little endian to the target's endianness.
+///
+/// On little endian, this is a no-op.  On big endian, the bytes are swapped.
 #[cfg(target_endian = "little")] #[inline] pub fn from_le32(x: i32) -> i32 { x }
+
+/// Convert an i32 from little endian to the target's endianness.
+///
+/// On little endian, this is a no-op.  On big endian, the bytes are swapped.
 #[cfg(target_endian = "big")]    #[inline] pub fn from_le32(x: i32) -> i32 { unsafe { bswap32(x) } }
+
+/// Convert an i64 from little endian to the target's endianness.
+///
+/// On little endian, this is a no-op.  On big endian, the bytes are swapped.
 #[cfg(target_endian = "little")] #[inline] pub fn from_le64(x: i64) -> i64 { x }
+
+/// Convert an i64 from little endian to the target's endianness.
+///
+/// On little endian, this is a no-op.  On big endian, the bytes are swapped.
 #[cfg(target_endian = "big")]    #[inline] pub fn from_le64(x: i64) -> i64 { unsafe { bswap64(x) } }
 
+
+/// Convert an i16 from big endian to the target's endianness.
+///
+/// On big endian, this is a no-op.  On little endian, the bytes are swapped.
 #[cfg(target_endian = "little")] #[inline] pub fn from_be16(x: i16) -> i16 { unsafe { bswap16(x) } }
+
+/// Convert an i16 from big endian to the target's endianness.
+///
+/// On big endian, this is a no-op.  On little endian, the bytes are swapped.
 #[cfg(target_endian = "big")]    #[inline] pub fn from_be16(x: i16) -> i16 { x }
+
+/// Convert an i32 from big endian to the target's endianness.
+///
+/// On big endian, this is a no-op.  On little endian, the bytes are swapped.
 #[cfg(target_endian = "little")] #[inline] pub fn from_be32(x: i32) -> i32 { unsafe { bswap32(x) } }
+
+/// Convert an i32 from big endian to the target's endianness.
+///
+/// On big endian, this is a no-op.  On little endian, the bytes are swapped.
 #[cfg(target_endian = "big")]    #[inline] pub fn from_be32(x: i32) -> i32 { x }
+
+/// Convert an i64 from big endian to the target's endianness.
+///
+/// On big endian, this is a no-op.  On little endian, the bytes are swapped.
 #[cfg(target_endian = "little")] #[inline] pub fn from_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
+
+/// Convert an i64 from big endian to the target's endianness.
+///
+/// On big endian, this is a no-op.  On little endian, the bytes are swapped.
 #[cfg(target_endian = "big")]    #[inline] pub fn from_be64(x: i64) -> i64 { x }