diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-12-14 23:24:36 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-12-19 10:51:00 -0500 |
| commit | a77e8a63d5d4c0fa04a878995824e727870135f9 (patch) | |
| tree | c422bcbfb5fe130035b38f2c7eb56e632845ca9a /src/libstd/io | |
| parent | 2df30a47e2e0ef563d9ed80cb3cc258cbea0f53a (diff) | |
| download | rust-a77e8a63d5d4c0fa04a878995824e727870135f9.tar.gz rust-a77e8a63d5d4c0fa04a878995824e727870135f9.zip | |
libstd: use `#[deriving(Copy)]`
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/mod.rs | 26 | ||||
| -rw-r--r-- | src/libstd/io/net/addrinfo.rs | 16 | ||||
| -rw-r--r-- | src/libstd/io/net/ip.rs | 9 | ||||
| -rw-r--r-- | src/libstd/io/process.rs | 8 | ||||
| -rw-r--r-- | src/libstd/io/util.rs | 9 |
5 files changed, 19 insertions, 49 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 5807a3bc466..dbf61b132e0 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -232,7 +232,6 @@ use error::{FromError, Error}; use fmt; use int; use iter::{Iterator, IteratorExt}; -use kinds::Copy; use mem::transmute; use ops::{BitOr, BitXor, BitAnd, Sub, Not, FnOnce}; use option::Option; @@ -367,7 +366,7 @@ impl FromError<IoError> for Box<Error> { } /// A list specifying general categories of I/O error. -#[deriving(PartialEq, Eq, Clone, Show)] +#[deriving(Copy, PartialEq, Eq, Clone, Show)] pub enum IoErrorKind { /// Any I/O error not part of this list. OtherIoError, @@ -422,8 +421,6 @@ pub enum IoErrorKind { NoProgress, } -impl Copy for IoErrorKind {} - /// A trait that lets you add a `detail` to an IoError easily trait UpdateIoError<T> { /// Returns an IoError with updated description and detail @@ -1561,6 +1558,7 @@ impl<T: Buffer> BufferPrelude for T { /// When seeking, the resulting cursor is offset from a base by the offset given /// to the `seek` function. The base used is specified by this enumeration. +#[deriving(Copy)] pub enum SeekStyle { /// Seek from the beginning of the stream SeekSet, @@ -1570,8 +1568,6 @@ pub enum SeekStyle { SeekCur, } -impl Copy for SeekStyle {} - /// An object implementing `Seek` internally has some form of cursor which can /// be moved within a stream of bytes. The stream typically has a fixed size, /// allowing seeking relative to either end. @@ -1685,6 +1681,7 @@ pub fn standard_error(kind: IoErrorKind) -> IoError { /// A mode specifies how a file should be opened or created. These modes are /// passed to `File::open_mode` and are used to control where the file is /// positioned when it is initially opened. +#[deriving(Copy)] pub enum FileMode { /// Opens a file positioned at the beginning. Open, @@ -1694,10 +1691,9 @@ pub enum FileMode { Truncate, } -impl Copy for FileMode {} - /// Access permissions with which the file should be opened. `File`s /// opened with `Read` will return an error if written to. +#[deriving(Copy)] pub enum FileAccess { /// Read-only access, requests to write will result in an error Read, @@ -1707,10 +1703,8 @@ pub enum FileAccess { ReadWrite, } -impl Copy for FileAccess {} - /// Different kinds of files which can be identified by a call to stat -#[deriving(PartialEq, Show, Hash, Clone)] +#[deriving(Copy, PartialEq, Show, Hash, Clone)] pub enum FileType { /// This is a normal file, corresponding to `S_IFREG` RegularFile, @@ -1731,8 +1725,6 @@ pub enum FileType { Unknown, } -impl Copy for FileType {} - /// A structure used to describe metadata information about a file. This /// structure is created through the `stat` method on a `Path`. /// @@ -1750,7 +1742,7 @@ impl Copy for FileType {} /// println!("byte size: {}", info.size); /// # } /// ``` -#[deriving(Hash)] +#[deriving(Copy, Hash)] pub struct FileStat { /// The size of the file, in bytes pub size: u64, @@ -1784,14 +1776,12 @@ pub struct FileStat { pub unstable: UnstableFileStat, } -impl Copy for FileStat {} - /// This structure represents all of the possible information which can be /// returned from a `stat` syscall which is not contained in the `FileStat` /// structure. This information is not necessarily platform independent, and may /// have different meanings or no meaning at all on some platforms. #[unstable] -#[deriving(Hash)] +#[deriving(Copy, Hash)] pub struct UnstableFileStat { /// The ID of the device containing the file. pub device: u64, @@ -1815,8 +1805,6 @@ pub struct UnstableFileStat { pub gen: u64, } -impl Copy for UnstableFileStat {} - bitflags! { #[doc = "A set of permissions for a file or directory is represented"] #[doc = "by a set of flags which are or'd together."] diff --git a/src/libstd/io/net/addrinfo.rs b/src/libstd/io/net/addrinfo.rs index fc81ab7b57a..69ba64d856e 100644 --- a/src/libstd/io/net/addrinfo.rs +++ b/src/libstd/io/net/addrinfo.rs @@ -22,23 +22,22 @@ pub use self::Protocol::*; use iter::IteratorExt; use io::{IoResult}; use io::net::ip::{SocketAddr, IpAddr}; -use kinds::Copy; use option::Option; use option::Option::{Some, None}; use sys; use vec::Vec; /// Hints to the types of sockets that are desired when looking up hosts +#[deriving(Copy)] pub enum SocketType { Stream, Datagram, Raw } -impl Copy for SocketType {} - /// Flags which can be or'd into the `flags` field of a `Hint`. These are used /// to manipulate how a query is performed. /// /// The meaning of each of these flags can be found with `man -s 3 getaddrinfo` +#[deriving(Copy)] pub enum Flag { AddrConfig, All, @@ -49,21 +48,19 @@ pub enum Flag { V4Mapped, } -impl Copy for Flag {} - /// A transport protocol associated with either a hint or a return value of /// `lookup` +#[deriving(Copy)] pub enum Protocol { TCP, UDP } -impl Copy for Protocol {} - /// This structure is used to provide hints when fetching addresses for a /// remote host to control how the lookup is performed. /// /// For details on these fields, see their corresponding definitions via /// `man -s 3 getaddrinfo` +#[deriving(Copy)] pub struct Hint { pub family: uint, pub socktype: Option<SocketType>, @@ -71,8 +68,7 @@ pub struct Hint { pub flags: uint, } -impl Copy for Hint {} - +#[deriving(Copy)] pub struct Info { pub address: SocketAddr, pub family: uint, @@ -81,8 +77,6 @@ pub struct Info { pub flags: uint, } -impl Copy for Info {} - /// Easy name resolution. Given a hostname, returns the list of IP addresses for /// that hostname. pub fn get_host_addresses(host: &str) -> IoResult<Vec<IpAddr>> { diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs index 5a3f5bd4668..71776b6c46a 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -18,7 +18,6 @@ pub use self::IpAddr::*; use fmt; -use kinds::Copy; use io::{mod, IoResult, IoError}; use io::net; use iter::{Iterator, IteratorExt}; @@ -32,14 +31,12 @@ use vec::Vec; pub type Port = u16; -#[deriving(PartialEq, Eq, Clone, Hash)] +#[deriving(Copy, PartialEq, Eq, Clone, Hash)] pub enum IpAddr { Ipv4Addr(u8, u8, u8, u8), Ipv6Addr(u16, u16, u16, u16, u16, u16, u16, u16) } -impl Copy for IpAddr {} - impl fmt::Show for IpAddr { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { @@ -65,14 +62,12 @@ impl fmt::Show for IpAddr { } } -#[deriving(PartialEq, Eq, Clone, Hash)] +#[deriving(Copy, PartialEq, Eq, Clone, Hash)] pub struct SocketAddr { pub ip: IpAddr, pub port: Port, } -impl Copy for SocketAddr {} - impl fmt::Show for SocketAddr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.ip { diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 60360a2bc64..9da1117f227 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -461,7 +461,7 @@ pub struct ProcessOutput { } /// Describes what to do with a standard io stream for a child process. -#[deriving(Clone)] +#[deriving(Clone, Copy)] pub enum StdioContainer { /// This stream will be ignored. This is the equivalent of attaching the /// stream to `/dev/null` @@ -481,11 +481,9 @@ pub enum StdioContainer { CreatePipe(bool /* readable */, bool /* writable */), } -impl Copy for StdioContainer {} - /// Describes the result of a process after it has terminated. /// Note that Windows have no signals, so the result is usually ExitStatus. -#[deriving(PartialEq, Eq, Clone)] +#[deriving(PartialEq, Eq, Clone, Copy)] pub enum ProcessExit { /// Normal termination with an exit status. ExitStatus(int), @@ -494,8 +492,6 @@ pub enum ProcessExit { ExitSignal(int), } -impl Copy for ProcessExit {} - impl fmt::Show for ProcessExit { /// Format a ProcessExit enum, to nicely present the information. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index faa52226a03..18fabcbd1a2 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -81,20 +81,18 @@ impl<R: Buffer> Buffer for LimitReader<R> { } /// A `Writer` which ignores bytes written to it, like /dev/null. +#[deriving(Copy)] pub struct NullWriter; -impl Copy for NullWriter {} - impl Writer for NullWriter { #[inline] fn write(&mut self, _buf: &[u8]) -> io::IoResult<()> { Ok(()) } } /// A `Reader` which returns an infinite stream of 0 bytes, like /dev/zero. +#[deriving(Copy)] pub struct ZeroReader; -impl Copy for ZeroReader {} - impl Reader for ZeroReader { #[inline] fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { @@ -113,10 +111,9 @@ impl Buffer for ZeroReader { } /// A `Reader` which is always at EOF, like /dev/null. +#[deriving(Copy)] pub struct NullReader; -impl Copy for NullReader {} - impl Reader for NullReader { #[inline] fn read(&mut self, _buf: &mut [u8]) -> io::IoResult<uint> { |
