Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the custom definition of Timespec to implement Copy. #484

Merged
merged 1 commit into from Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, I thought I tried this and it didn't work, but if it does great!

#[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