@@ -26,11 +26,14 @@ fn as_hex(data: ~[u8]) -> ~str {
2626 return acc;
2727}
2828
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+ }
3437}
3538
3639fn main() {
@@ -225,13 +228,15 @@ struct timeval {
225228extern mod lib_c {
226229 fn gettimeofday(tv: *timeval, tz: *()) -> i32;
227230}
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+ }
235240}
236241
237242# fn main() { assert fmt!("%?", unix_time_in_microseconds()) != ~""; }
0 commit comments