about summary refs log tree commit diff
path: root/src/libuuid/lib.rs
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2014-04-14 20:04:14 +1000
committerAlex Crichton <alex@alexcrichton.com>2014-04-15 19:45:00 -0700
commit54ec04f1c12c7fb4dbe5f01fdeb73d1079fef53d (patch)
treeefe91e930ac4527e3057fe65571df112ef5b8607 /src/libuuid/lib.rs
parent93dc55518840ee3cbd570c0d85aa7a445752af8b (diff)
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.
Diffstat (limited to 'src/libuuid/lib.rs')
-rw-r--r--src/libuuid/lib.rs12
1 files changed, 6 insertions, 6 deletions
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,