diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index c436de0d193..2c4dc5313bb 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -18,7 +18,6 @@ use core::kinds::Sized; use fmt; use iter::IteratorExt; -use kinds::Copy; use mem; use ops::FnMut; use option::Option; @@ -29,11 +28,9 @@ use string::{String, IntoString}; use vec::Vec; /// Datatype to hold one ascii character. It wraps a `u8`, with the highest bit always zero. -#[deriving(Clone, PartialEq, PartialOrd, Ord, Eq, Hash)] +#[deriving(Clone, Copy, PartialEq, PartialOrd, Ord, Eq, Hash)] pub struct Ascii { chr: u8 } -impl Copy for Ascii {} - impl Ascii { /// Converts an ascii character into a `u8`. #[inline] diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index 8f945fec4d5..9043cb8c7d6 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -391,7 +391,7 @@ pub struct SyncSender { /// This enumeration is the list of the possible reasons that try_recv could not /// return data when called. -#[deriving(PartialEq, Clone, Show)] +#[deriving(PartialEq, Clone, Copy, Show)] #[experimental = "this is likely to be removed in changing try_recv()"] pub enum TryRecvError { /// This channel is currently empty, but the sender(s) have not yet @@ -402,8 +402,6 @@ pub enum TryRecvError { Disconnected, } -impl Copy for TryRecvError {} - /// This enumeration is the list of the possible error outcomes for the /// `SyncSender::try_send` method. #[deriving(PartialEq, Clone, Show)] diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index 758dab1a107..291f384d619 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -215,7 +215,6 @@ pub mod dl { use c_str::{CString, ToCStr}; use libc; - use kinds::Copy; use ops::FnOnce; use ptr; use result::*; @@ -265,6 +264,7 @@ pub mod dl { dlclose(handle as *mut libc::c_void); () } + #[deriving(Copy)] pub enum Rtld { Lazy = 1, Now = 2, @@ -272,8 +272,6 @@ pub mod dl { Local = 0, } - impl Copy for Rtld {} - #[link_name = "dl"] extern { fn dlopen(filename: *const libc::c_char, 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 for Box { } /// 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 { /// Returns an IoError with updated description and detail @@ -1561,6 +1558,7 @@ impl 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, @@ -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> { 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 Buffer for LimitReader { } /// 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 { @@ -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 { diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 2b319640d1b..016c4bd532a 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -17,7 +17,6 @@ pub use self::SignificantDigits::*; pub use self::SignFormat::*; use char::{mod, Char}; -use kinds::Copy; use num::{mod, Int, Float, FPNaN, FPInfinite, ToPrimitive}; use ops::FnMut; use slice::{SliceExt, CloneSliceExt}; @@ -26,6 +25,7 @@ use string::String; use vec::Vec; /// A flag that specifies whether to use exponential (scientific) notation. +#[deriving(Copy)] pub enum ExponentFormat { /// Do not use exponential notation. ExpNone, @@ -38,10 +38,9 @@ pub enum ExponentFormat { ExpBin, } -impl Copy for ExponentFormat {} - /// The number of digits used for emitting the fractional part of a number, if /// any. +#[deriving(Copy)] pub enum SignificantDigits { /// All calculable digits will be printed. /// @@ -57,9 +56,8 @@ pub enum SignificantDigits { DigExact(uint) } -impl Copy for SignificantDigits {} - /// How to emit the sign of a number. +#[deriving(Copy)] pub enum SignFormat { /// No sign will be printed. The exponent sign will also be emitted. SignNone, @@ -71,8 +69,6 @@ pub enum SignFormat { SignAll, } -impl Copy for SignFormat {} - /// Converts an integral number to its string representation as a byte vector. /// This is meant to be a common base implementation for all integral string /// conversion functions like `to_string()` or `to_str_radix()`. diff --git a/src/libstd/os.rs b/src/libstd/os.rs index a049ea01b6d..dcc73f7844a 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -361,6 +361,7 @@ pub fn join_paths(paths: &[T]) -> Result, &'static st } /// A low-level OS in-memory pipe. +#[deriving(Copy)] pub struct Pipe { /// A file descriptor representing the reading end of the pipe. Data written /// on the `out` file descriptor can be read from this file descriptor. @@ -370,8 +371,6 @@ pub struct Pipe { pub writer: c_int, } -impl Copy for Pipe {} - /// Creates a new low-level OS in-memory pipe. /// /// This function can fail to succeed if there are no more resources available @@ -861,6 +860,7 @@ pub enum MapOption { impl Copy for MapOption {} /// Possible errors when creating a map. +#[deriving(Copy)] pub enum MapError { /// # The following are POSIX-specific /// @@ -905,8 +905,6 @@ pub enum MapError { ErrMapViewOfFile(uint) } -impl Copy for MapError {} - impl fmt::Show for MapError { fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result { let str = match *self { diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 5cbefb0d3d8..b498b3e8ad0 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -22,7 +22,6 @@ use hash; use io::Writer; use iter::{AdditiveIterator, DoubleEndedIteratorExt, Extend}; use iter::{Iterator, IteratorExt, Map}; -use kinds::Copy; use mem; use option::Option; use option::Option::{Some, None}; @@ -970,7 +969,7 @@ pub fn is_sep_byte_verbatim(u: &u8) -> bool { } /// Prefix types for Path -#[deriving(PartialEq, Clone, Show)] +#[deriving(Copy, PartialEq, Clone, Show)] pub enum PathPrefix { /// Prefix `\\?\`, uint is the length of the following component VerbatimPrefix(uint), @@ -986,8 +985,6 @@ pub enum PathPrefix { DiskPrefix } -impl Copy for PathPrefix {} - fn parse_prefix<'a>(mut path: &'a str) -> Option { if path.starts_with("\\\\") { // \\ diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index d8e1fc25654..0035e5747aa 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -225,7 +225,6 @@ use cell::RefCell; use clone::Clone; use io::IoResult; use iter::{Iterator, IteratorExt}; -use kinds::Copy; use mem; use rc::Rc; use result::Result::{Ok, Err}; @@ -246,12 +245,11 @@ pub mod reader; /// The standard RNG. This is designed to be efficient on the current /// platform. +#[deriving(Copy)] pub struct StdRng { rng: IsaacWordRng, } -impl Copy for StdRng {} - impl StdRng { /// Create a randomly seeded instance of `StdRng`. /// diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index 85ed27853c4..7cb14e8e4bc 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -13,7 +13,6 @@ #![experimental] use {fmt, i64}; -use kinds::Copy; use ops::{Add, Sub, Mul, Div, Neg, FnOnce}; use option::Option; use option::Option::{Some, None}; @@ -47,7 +46,7 @@ macro_rules! try_opt { /// ISO 8601 time duration with nanosecond precision. /// This also allows for the negative duration; see individual methods for details. -#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)] +#[deriving(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Duration { secs: i64, nanos: i32, // Always 0 <= nanos < NANOS_PER_SEC @@ -65,8 +64,6 @@ pub const MAX: Duration = Duration { nanos: (i64::MAX % MILLIS_PER_SEC) as i32 * NANOS_PER_MILLI }; -impl Copy for Duration {} - impl Duration { /// Makes a new `Duration` with given number of weeks. /// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60), with overflow checks.