Skip to content

Commit 52fc789

Browse files
authored
Fix the custom definition of Timespec to implement Copy. (#484)
1 parent df79636 commit 52fc789

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/backend/libc/time/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub type Timespec = c::timespec;
1616
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
1717
target_env = "gnu",
1818
))]
19-
#[derive(Debug, Clone)]
19+
#[derive(Debug, Clone, Copy)]
2020
#[repr(C)]
2121
pub struct Timespec {
2222
/// Seconds.

tests/time/timespec.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ fn test_timespec_layout() {
66

77
let tv_sec: Secs = 0;
88
let tv_nsec: Nsecs = 0;
9-
let _ = Timespec { tv_sec, tv_nsec };
9+
let x = Timespec { tv_sec, tv_nsec };
10+
11+
// Test that `Timespec` implements `Copy` and `Debug`.
12+
let _y = Timespec { tv_sec, tv_nsec };
13+
let _z = Timespec { tv_sec, tv_nsec };
14+
dbg!(&x);
1015

1116
#[cfg(not(target_os = "redox"))]
1217
let _ = Timespec {

0 commit comments

Comments
 (0)