From 54ec04f1c12c7fb4dbe5f01fdeb73d1079fef53d Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Mon, 14 Apr 2014 20:04:14 +1000 Subject: Use the unsigned integer types for bitwise intrinsics. Exposing ctpop, ctlz, cttz and bswap as taking signed i8/i16/... is just exposing the internal LLVM names pointlessly (LLVM doesn't have "signed integers" or "unsigned integers", it just has sized integer types with (un)signed *operations*). These operations are semantically working with raw bytes, which the unsigned types model better. --- src/libuuid/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/libuuid/lib.rs') diff --git a/src/libuuid/lib.rs b/src/libuuid/lib.rs index 2ac6780af4c..559edd587fd 100644 --- a/src/libuuid/lib.rs +++ b/src/libuuid/lib.rs @@ -220,9 +220,9 @@ impl Uuid { data4: [0, ..8] }; - fields.data1 = to_be32(d1 as i32) as u32; - fields.data2 = to_be16(d2 as i16) as u16; - fields.data3 = to_be16(d3 as i16) as u16; + fields.data1 = to_be32(d1); + fields.data2 = to_be16(d2); + fields.data3 = to_be16(d3); slice::bytes::copy_memory(fields.data4, d4); unsafe { @@ -343,9 +343,9 @@ impl Uuid { unsafe { uf = transmute_copy(&self.bytes); } - uf.data1 = to_be32(uf.data1 as i32) as u32; - uf.data2 = to_be16(uf.data2 as i16) as u16; - uf.data3 = to_be16(uf.data3 as i16) as u16; + uf.data1 = to_be32(uf.data1); + uf.data2 = to_be16(uf.data2); + uf.data3 = to_be16(uf.data3); let s = format!("{:08x}-{:04x}-{:04x}-{:02x}{:02x}-\ {:02x}{:02x}{:02x}{:02x}{:02x}{:02x}", uf.data1, -- cgit 1.4.1-3-g733a5