]> git.lizzy.rs Git - rust.git/commitdiff
libstd: use `#[deriving(Copy)]`
authorJorge Aparicio <japaricious@gmail.com>
Mon, 15 Dec 2014 04:24:36 +0000 (23:24 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Fri, 19 Dec 2014 15:51:00 +0000 (10:51 -0500)
13 files changed:
src/libstd/ascii.rs
src/libstd/comm/mod.rs
src/libstd/dynamic_lib.rs
src/libstd/io/mod.rs
src/libstd/io/net/addrinfo.rs
src/libstd/io/net/ip.rs
src/libstd/io/process.rs
src/libstd/io/util.rs
src/libstd/num/strconv.rs
src/libstd/os.rs
src/libstd/path/windows.rs
src/libstd/rand/mod.rs
src/libstd/time/duration.rs

index c436de0d193b8b38930edba18e01737821060786..2c4dc5313bbfa0af2569e54082ea4c468a56d162 100644 (file)
@@ -18,7 +18,6 @@
 use core::kinds::Sized;
 use fmt;
 use iter::IteratorExt;
-use kinds::Copy;
 use mem;
 use ops::FnMut;
 use option::Option;
 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]
index 8f945fec4d5625b766e8bdfdf9f06dd57224613b..9043cb8c7d6f5f6b40632d10e27b0716a81fe4e7 100644 (file)
@@ -391,7 +391,7 @@ pub struct SyncSender<T> {
 
 /// 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)]
index 758dab1a10726b0549b5133550e10293e255f5e9..291f384d619d9726adcc8bdf75eb4617959cc186 100644 (file)
@@ -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 unsafe fn close(handle: *mut u8) {
         dlclose(handle as *mut libc::c_void); ()
     }
 
+    #[deriving(Copy)]
     pub enum Rtld {
         Lazy = 1,
         Now = 2,
@@ -272,8 +272,6 @@ pub enum Rtld {
         Local = 0,
     }
 
-    impl Copy for Rtld {}
-
     #[link_name = "dl"]
     extern {
         fn dlopen(filename: *const libc::c_char,
index 5807a3bc4662e436d1f7c70e5fb7fa383ddc9c2b..dbf61b132e08b3a556177a4a40f5206a23edcc5d 100644 (file)
 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 @@ fn from_error(err: IoError) -> 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 @@ fn lines<'r>(&'r mut self) -> Lines<'r, 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."]
index fc81ab7b57a3ef34076a83acaa0c9a59e3546ab6..69ba64d856e7f325b2781f98dfef299ea7b4c485 100644 (file)
 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>> {
index 5a3f5bd466884a1279a5478d64d7048610cbd28b..71776b6c46af79cd1daef6ed707872694287deef 100644 (file)
@@ -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};
 
 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 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-#[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 {
index 60360a2bc6445cf29d6c5618632a2f782f3a9944..9da1117f2272aab95a6f1ac6429cc0df6fa33345 100644 (file)
@@ -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 {
index faa52226a03b7f996448b5eaa7b3650ad2ce83b0..18fabcbd1a2a4792e6afc311d389985a0bdcd126 100644 (file)
@@ -81,20 +81,18 @@ fn consume(&mut self, amt: uint) {
 }
 
 /// 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 @@ fn consume(&mut self, _amt: uint) {}
 }
 
 /// 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> {
index 2b319640d1b4e31f55153e190098aafd38250825..016c4bd532a17e52c7dbf54796139a8b64e1bd43 100644 (file)
@@ -17,7 +17,6 @@
 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 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()`.
index a049ea01b6d49c7e3a67cea0eaee9e50f0de08f0..dcc73f7844a4987b57d02f7523df7fe1558ddc44 100644 (file)
@@ -361,6 +361,7 @@ pub fn join_paths<T: BytesContainer>(paths: &[T]) -> Result<Vec<u8>, &'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 {
index 5cbefb0d3d8e0016a887fc964686685ce85d6ece..b498b3e8ad08350cc9970bda56077d7e766cc11e 100644 (file)
@@ -22,7 +22,6 @@
 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<PathPrefix> {
     if path.starts_with("\\\\") {
         // \\
index d8e1fc2565469c72968068b24f814dbac51ef072..0035e5747aa6915c03c8a65ab93150a7ec764c26 100644 (file)
 use clone::Clone;
 use io::IoResult;
 use iter::{Iterator, IteratorExt};
-use kinds::Copy;
 use mem;
 use rc::Rc;
 use result::Result::{Ok, Err};
 
 /// 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`.
     ///
index 85ed27853c4544793a4f0e45fe036a08ab50849f..7cb14e8e4bc62fe33d057509cbb5a6cfeee42679 100644 (file)
@@ -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 struct 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.