From b40163beb925b176fdb570e4f4998ab9919e77a4 Mon Sep 17 00:00:00 2001 From: Ben S Date: Tue, 13 Oct 2015 13:06:00 +0100 Subject: Make the Metadata struct Clone This commit adds #[derive(Clone)] to std::fs::Metadata, making that struct cloneable. Although the exact contents of that struct differ between OSes, they all have it contain only value types, meaning that the data can be re-used without repercussions. It also adds #[derive(Clone)] to every type used by that struct across all OSes, including the various Unix `stat` structs and Windows's `WIN32_FILE_ATTRIBUTE_DATA`. --- src/libstd/os/android/raw.rs | 2 ++ src/libstd/os/bitrig/raw.rs | 1 + src/libstd/os/dragonfly/raw.rs | 1 + src/libstd/os/freebsd/raw.rs | 2 ++ src/libstd/os/ios/raw.rs | 1 + src/libstd/os/linux/raw.rs | 4 ++++ src/libstd/os/macos/raw.rs | 1 + src/libstd/os/nacl/raw.rs | 4 ++++ src/libstd/os/netbsd/raw.rs | 1 + src/libstd/os/openbsd/raw.rs | 1 + 10 files changed, 18 insertions(+) (limited to 'src/libstd/os') diff --git a/src/libstd/os/android/raw.rs b/src/libstd/os/android/raw.rs index cad80c55140..391ca16f692 100644 --- a/src/libstd/os/android/raw.rs +++ b/src/libstd/os/android/raw.rs @@ -39,6 +39,7 @@ mod arch { pub type time_t = i32; #[repr(C)] + #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] @@ -108,6 +109,7 @@ mod arch { pub type time_t = i64; #[repr(C)] + #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] diff --git a/src/libstd/os/bitrig/raw.rs b/src/libstd/os/bitrig/raw.rs index 2427a4e4092..45e46b252a4 100644 --- a/src/libstd/os/bitrig/raw.rs +++ b/src/libstd/os/bitrig/raw.rs @@ -26,6 +26,7 @@ use os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; #[repr(C)] +#[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] diff --git a/src/libstd/os/dragonfly/raw.rs b/src/libstd/os/dragonfly/raw.rs index 1c265fa62f1..cb692b0662a 100644 --- a/src/libstd/os/dragonfly/raw.rs +++ b/src/libstd/os/dragonfly/raw.rs @@ -26,6 +26,7 @@ use os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; #[repr(C)] +#[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] diff --git a/src/libstd/os/freebsd/raw.rs b/src/libstd/os/freebsd/raw.rs index 761e6c96ab7..2dc9a026153 100644 --- a/src/libstd/os/freebsd/raw.rs +++ b/src/libstd/os/freebsd/raw.rs @@ -33,6 +33,7 @@ mod arch { #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32; #[repr(C)] + #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] @@ -91,6 +92,7 @@ mod arch { #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; #[repr(C)] + #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] diff --git a/src/libstd/os/ios/raw.rs b/src/libstd/os/ios/raw.rs index a9803f50b7b..aeb3e993a72 100644 --- a/src/libstd/os/ios/raw.rs +++ b/src/libstd/os/ios/raw.rs @@ -25,6 +25,7 @@ use os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = c_long; #[repr(C)] +#[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] diff --git a/src/libstd/os/linux/raw.rs b/src/libstd/os/linux/raw.rs index 3275ce07b48..d7abdef6b03 100644 --- a/src/libstd/os/linux/raw.rs +++ b/src/libstd/os/linux/raw.rs @@ -35,6 +35,7 @@ mod arch { #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32; #[repr(C)] + #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] @@ -95,6 +96,7 @@ mod arch { #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32; #[repr(C)] + #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] @@ -154,6 +156,7 @@ mod arch { #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; #[repr(C)] + #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] @@ -211,6 +214,7 @@ mod arch { #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; #[repr(C)] + #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] diff --git a/src/libstd/os/macos/raw.rs b/src/libstd/os/macos/raw.rs index dbc1b8c726b..4abd6f2d4de 100644 --- a/src/libstd/os/macos/raw.rs +++ b/src/libstd/os/macos/raw.rs @@ -25,6 +25,7 @@ use os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = c_long; #[repr(C)] +#[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] diff --git a/src/libstd/os/nacl/raw.rs b/src/libstd/os/nacl/raw.rs index d811b94c847..82898437687 100644 --- a/src/libstd/os/nacl/raw.rs +++ b/src/libstd/os/nacl/raw.rs @@ -34,6 +34,7 @@ mod arch { #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32; #[repr(C)] + #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] @@ -94,6 +95,7 @@ mod arch { #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32; #[repr(C)] + #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] @@ -153,6 +155,7 @@ mod arch { #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; #[repr(C)] + #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] @@ -210,6 +213,7 @@ mod arch { #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; #[repr(C)] + #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] diff --git a/src/libstd/os/netbsd/raw.rs b/src/libstd/os/netbsd/raw.rs index 09adc1d05a6..882d08c6606 100644 --- a/src/libstd/os/netbsd/raw.rs +++ b/src/libstd/os/netbsd/raw.rs @@ -26,6 +26,7 @@ use os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; #[repr(C)] +#[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] diff --git a/src/libstd/os/openbsd/raw.rs b/src/libstd/os/openbsd/raw.rs index 79ca901ade7..1cc0eedfcd0 100644 --- a/src/libstd/os/openbsd/raw.rs +++ b/src/libstd/os/openbsd/raw.rs @@ -26,6 +26,7 @@ use os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; #[repr(C)] +#[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] -- cgit 1.4.1-3-g733a5