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`.
This commit is contained in:
parent
ec4362da56
commit
b40163beb9
14 changed files with 22 additions and 0 deletions
|
@ -60,6 +60,7 @@ pub struct File {
|
||||||
/// represents known metadata about a file such as its permissions, size,
|
/// represents known metadata about a file such as its permissions, size,
|
||||||
/// modification times, etc.
|
/// modification times, etc.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct Metadata(fs_imp::FileAttr);
|
pub struct Metadata(fs_imp::FileAttr);
|
||||||
|
|
||||||
/// Iterator over the entries in a directory.
|
/// Iterator over the entries in a directory.
|
||||||
|
|
|
@ -39,6 +39,7 @@ mod arch {
|
||||||
pub type time_t = i32;
|
pub type time_t = i32;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
|
@ -108,6 +109,7 @@ mod arch {
|
||||||
pub type time_t = i64;
|
pub type time_t = i64;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
|
|
|
@ -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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
|
|
|
@ -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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
|
|
|
@ -33,6 +33,7 @@ mod arch {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
|
|
|
@ -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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = c_long;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
|
|
|
@ -35,6 +35,7 @@ mod arch {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
|
|
|
@ -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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = c_long;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
|
|
|
@ -34,6 +34,7 @@ mod arch {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
|
|
|
@ -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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
|
|
|
@ -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;
|
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
pub struct stat {
|
pub struct stat {
|
||||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||||
|
|
|
@ -27,6 +27,7 @@ use vec::Vec;
|
||||||
|
|
||||||
pub struct File(FileDesc);
|
pub struct File(FileDesc);
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct FileAttr {
|
pub struct FileAttr {
|
||||||
stat: raw::stat,
|
stat: raw::stat,
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,6 +182,7 @@ pub struct CONSOLE_SCREEN_BUFFER_INFO {
|
||||||
pub type PCONSOLE_SCREEN_BUFFER_INFO = *mut CONSOLE_SCREEN_BUFFER_INFO;
|
pub type PCONSOLE_SCREEN_BUFFER_INFO = *mut CONSOLE_SCREEN_BUFFER_INFO;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct WIN32_FILE_ATTRIBUTE_DATA {
|
pub struct WIN32_FILE_ATTRIBUTE_DATA {
|
||||||
pub dwFileAttributes: libc::DWORD,
|
pub dwFileAttributes: libc::DWORD,
|
||||||
pub ftCreationTime: libc::FILETIME,
|
pub ftCreationTime: libc::FILETIME,
|
||||||
|
|
|
@ -27,6 +27,7 @@ use vec::Vec;
|
||||||
|
|
||||||
pub struct File { handle: Handle }
|
pub struct File { handle: Handle }
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct FileAttr {
|
pub struct FileAttr {
|
||||||
data: c::WIN32_FILE_ATTRIBUTE_DATA,
|
data: c::WIN32_FILE_ATTRIBUTE_DATA,
|
||||||
reparse_tag: libc::DWORD,
|
reparse_tag: libc::DWORD,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue