Skip to content

Commit f4eb25e

Browse files
committed
tutorial: Fix type mismatch in example FFI code
Compile error: time.rs:13:23: 13:43 error: mismatched types: expected *R[tv_sec=mMltv_usec=mMl] but found *R[tv_sec=Mltv_usec=Ml] (record elements differ in mutability) time.rs:13 libc::gettimeofday(std::ptr::addr_of(x), std::ptr::null()); ^~~~~~~~~~~~~~~~~~~~ error: aborting due to previous errors rust: upcall fail 'explicit failure', ../src/comp/driver/session.rs:70 rust: domain main @0x9dfd178 root task failed
1 parent 388eed3 commit f4eb25e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

doc/tutorial/ffi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ microsecond-resolution timer.
183183
fn gettimeofday(tv: *timeval, tz: *()) -> i32;
184184
}
185185
fn unix_time_in_microseconds() -> u64 unsafe {
186-
let x = {tv_sec: 0u32, tv_usec: 0u32};
186+
let x = {mutable tv_sec: 0u32, mutable tv_usec: 0u32};
187187
libc::gettimeofday(std::ptr::addr_of(x), std::ptr::null());
188188
ret (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
189189
}

0 commit comments

Comments
 (0)