Skip to content

Commit 6d360d2

Browse files
committed
tutorial: Fix types in gettimeofday example. Closes #1657
1 parent 5e250b6 commit 6d360d2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

doc/tutorial.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,17 +2334,19 @@ microsecond-resolution timer.
23342334

23352335
~~~~
23362336
use std;
2337-
type timeval = {mutable tv_sec: u32,
2338-
mutable tv_usec: u32};
2337+
type timeval = {mutable tv_sec: uint,
2338+
mutable tv_usec: uint};
23392339
#[nolink]
23402340
native mod libc {
23412341
fn gettimeofday(tv: *timeval, tz: *()) -> i32;
23422342
}
23432343
fn unix_time_in_microseconds() -> u64 unsafe {
2344-
let x = {mutable tv_sec: 0u32, mutable tv_usec: 0u32};
2344+
let x = {mutable tv_sec: 0u, mutable tv_usec: 0u};
23452345
libc::gettimeofday(ptr::addr_of(x), ptr::null());
23462346
ret (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
23472347
}
2348+
2349+
# fn main() { assert #fmt("%?", unix_time_in_microseconds()) != ""; }
23482350
~~~~
23492351

23502352
The `#[nolink]` attribute indicates that there's no native library to link

0 commit comments

Comments
 (0)