Skip to content

Commit

Permalink
Implement Copy/Clone for all types missing it
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryant Mairs committed Jan 15, 2018
1 parent 29679a4 commit 429af5e
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
Errno::result(res)
}

#[derive(Clone, Copy)]
pub enum FlockArg {
LockShared,
LockExclusive,
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#![deny(unused_qualifications)]
#![deny(unstable_features)]
#![deny(unused_import_braces)]
#![deny(missing_copy_implementations)]

#[macro_use]
extern crate bitflags;
Expand Down
1 change: 1 addition & 0 deletions src/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use errno::Errno;
///
/// This is returned by `openpty`. Note that this type does *not* implement `Drop`, so the user
/// must manually close the file descriptors.
#[derive(Clone, Copy)]
pub struct OpenptyResult {
pub master: RawFd,
pub slave: RawFd,
Expand Down
1 change: 1 addition & 0 deletions src/sys/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub use libc::FD_SETSIZE;

// FIXME: Change to repr(transparent) once it's stable
#[repr(C)]
#[derive(Clone, Copy)]
pub struct FdSet(libc::fd_set);

impl FdSet {
Expand Down
3 changes: 3 additions & 0 deletions src/sys/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ const SIGNALS: [Signal; 31] = [

pub const NSIG: libc::c_int = 32;

#[derive(Clone, Copy)]
pub struct SignalIterator {
next: usize,
}
Expand Down Expand Up @@ -359,6 +360,7 @@ pub enum SigHandler {
SigAction(extern fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void))
}

#[derive(Clone, Copy)]
pub struct SigAction {
sigaction: libc::sigaction
}
Expand Down Expand Up @@ -528,6 +530,7 @@ mod sigevent {
/// Used to request asynchronous notification of the completion of certain
/// events, such as POSIX AIO and timers.
#[repr(C)]
#[derive(Clone, Copy)]
pub struct SigEvent {
sigevent: libc::sigevent
}
Expand Down
2 changes: 1 addition & 1 deletion src/sys/socket/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl fmt::Debug for InetAddr {
* ===== IpAddr =====
*
*/

#[derive(Clone, Copy)]
pub enum IpAddr {
V4(Ipv4Addr),
V6(Ipv6Addr),
Expand Down
1 change: 1 addition & 0 deletions src/sys/statvfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ libc_bitflags!(
/// For more information see the [`statvfs(3)` man pages](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_statvfs.h.html).
// FIXME: Replace with repr(transparent)
#[repr(C)]
#[derive(Clone, Copy)]
pub struct Statvfs(libc::statvfs);

impl Statvfs {
Expand Down
1 change: 1 addition & 0 deletions src/sys/uio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub fn pread(fd: RawFd, buf: &mut [u8], offset: off_t) -> Result<usize>{
/// and [`process_vm_writev`](fn.process_vm_writev.html).
#[cfg(target_os = "linux")]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct RemoteIoVec {
/// The starting address of this slice (`iov_base`).
pub base: usize,
Expand Down
1 change: 1 addition & 0 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ pub fn write(fd: RawFd, buf: &[u8]) -> Result<usize> {
/// [`lseek`]: ./fn.lseek.html
/// [`lseek64`]: ./fn.lseek64.html
#[repr(i32)]
#[derive(Clone, Copy)]
pub enum Whence {
/// Specify an offset relative to the start of the file.
SeekSet = libc::SEEK_SET,
Expand Down

0 comments on commit 429af5e

Please sign in to comment.