@@ -26,11 +26,14 @@ fn as_hex(data: ~[u8]) -> ~str {
26
26
return acc;
27
27
}
28
28
29
- fn sha1(data: ~str) -> ~str unsafe {
30
- let bytes = str::to_bytes(data);
31
- let hash = crypto::SHA1(vec::raw::to_ptr(bytes),
32
- vec::len(bytes) as c_uint, ptr::null());
33
- return as_hex(vec::from_buf(hash, 20));
29
+ fn sha1(data: ~str) -> ~str {
30
+ unsafe {
31
+ let bytes = str::to_bytes(data);
32
+ let hash = crypto::SHA1(vec::raw::to_ptr(bytes),
33
+ vec::len(bytes) as c_uint,
34
+ ptr::null());
35
+ return as_hex(vec::from_buf(hash, 20));
36
+ }
34
37
}
35
38
36
39
fn main() {
@@ -225,13 +228,15 @@ struct timeval {
225
228
extern mod lib_c {
226
229
fn gettimeofday(tv: *timeval, tz: *()) -> i32;
227
230
}
228
- fn unix_time_in_microseconds() -> u64 unsafe {
229
- let x = timeval {
230
- mut tv_sec: 0 as c_ulonglong,
231
- mut tv_usec: 0 as c_ulonglong
232
- };
233
- lib_c::gettimeofday(ptr::addr_of(&x), ptr::null());
234
- return (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
231
+ fn unix_time_in_microseconds() -> u64 {
232
+ unsafe {
233
+ let x = timeval {
234
+ mut tv_sec: 0 as c_ulonglong,
235
+ mut tv_usec: 0 as c_ulonglong
236
+ };
237
+ lib_c::gettimeofday(ptr::addr_of(&x), ptr::null());
238
+ return (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
239
+ }
235
240
}
236
241
237
242
# fn main() { assert fmt!("%?", unix_time_in_microseconds()) != ~""; }
0 commit comments