Skip to content

Commit

Permalink
Fix the custom definition of Timespec to implement Copy. (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Dec 13, 2022
1 parent df79636 commit 52fc789
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/backend/libc/time/types.rs
Expand Up @@ -16,7 +16,7 @@ pub type Timespec = c::timespec;
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu",
))]
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub struct Timespec {
/// Seconds.
Expand Down
7 changes: 6 additions & 1 deletion tests/time/timespec.rs
Expand Up @@ -6,7 +6,12 @@ fn test_timespec_layout() {

let tv_sec: Secs = 0;
let tv_nsec: Nsecs = 0;
let _ = Timespec { tv_sec, tv_nsec };
let x = Timespec { tv_sec, tv_nsec };

// Test that `Timespec` implements `Copy` and `Debug`.
let _y = Timespec { tv_sec, tv_nsec };
let _z = Timespec { tv_sec, tv_nsec };
dbg!(&x);

#[cfg(not(target_os = "redox"))]
let _ = Timespec {
Expand Down

0 comments on commit 52fc789

Please sign in to comment.