diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ascii.rs | 3 | ||||
| -rw-r--r-- | src/libstd/bitflags.rs | 9 | ||||
| -rw-r--r-- | src/libstd/collections/hash/table.rs | 6 | ||||
| -rw-r--r-- | src/libstd/comm/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/dynamic_lib.rs | 8 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 17 | ||||
| -rw-r--r-- | src/libstd/io/net/addrinfo.rs | 11 | ||||
| -rw-r--r-- | src/libstd/io/net/ip.rs | 5 | ||||
| -rw-r--r-- | src/libstd/io/process.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io/util.rs | 6 | ||||
| -rw-r--r-- | src/libstd/num/strconv.rs | 51 | ||||
| -rw-r--r-- | src/libstd/os.rs | 12 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 3 | ||||
| -rw-r--r-- | src/libstd/rand/mod.rs | 7 | ||||
| -rw-r--r-- | src/libstd/time/duration.rs | 3 |
15 files changed, 125 insertions, 22 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 2872f74cf88..23eb367dbd1 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -18,6 +18,7 @@ use core::kinds::Sized; use fmt; use iter::IteratorExt; +use kinds::Copy; use mem; use option::Option; use option::Option::{Some, None}; @@ -30,6 +31,8 @@ use vec::Vec; #[deriving(Clone, 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/bitflags.rs b/src/libstd/bitflags.rs index 8a90c06f038..ffcd6505dad 100644 --- a/src/libstd/bitflags.rs +++ b/src/libstd/bitflags.rs @@ -33,6 +33,8 @@ /// } /// } /// +/// impl Copy for Flags {} +/// /// fn main() { /// let e1 = FLAG_A | FLAG_C; /// let e2 = FLAG_B | FLAG_C; @@ -55,6 +57,8 @@ /// } /// } /// +/// impl Copy for Flags {} +/// /// impl Flags { /// pub fn clear(&mut self) { /// self.bits = 0; // The `bits` field can be accessed from within the @@ -260,6 +264,7 @@ macro_rules! bitflags { #[cfg(test)] #[allow(non_upper_case_globals)] mod tests { + use kinds::Copy; use hash; use option::Option::{Some, None}; use ops::{BitOr, BitAnd, BitXor, Sub, Not}; @@ -283,12 +288,16 @@ mod tests { } } + impl Copy for Flags {} + bitflags! { flags AnotherSetOfFlags: i8 { const AnotherFlag = -1_i8, } } + impl Copy for AnotherSetOfFlags {} + #[test] fn test_bits(){ assert_eq!(Flags::empty().bits(), 0x00000000); diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index de06a1e0bbd..ef4cabedc47 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -16,7 +16,7 @@ use clone::Clone; use cmp; use hash::{Hash, Hasher}; use iter::{Iterator, count}; -use kinds::{Sized, marker}; +use kinds::{Copy, Sized, marker}; use mem::{min_align_of, size_of}; use mem; use num::{Int, UnsignedInt}; @@ -81,12 +81,16 @@ struct RawBucket<K, V> { val: *mut V } +impl<K,V> Copy for RawBucket<K,V> {} + pub struct Bucket<K, V, M> { raw: RawBucket<K, V>, idx: uint, table: M } +impl<K,V,M:Copy> Copy for Bucket<K,V,M> {} + pub struct EmptyBucket<K, V, M> { raw: RawBucket<K, V>, idx: uint, diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index d291ed72567..6cff5a3dd23 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -405,6 +405,8 @@ 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 aa0c8b53c2e..5609fbf16cd 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -29,7 +29,10 @@ use str; use string::String; use vec::Vec; -pub struct DynamicLibrary { handle: *mut u8 } +#[allow(missing_copy_implementations)] +pub struct DynamicLibrary { + handle: *mut u8 +} impl Drop for DynamicLibrary { fn drop(&mut self) { @@ -210,6 +213,7 @@ pub mod dl { use c_str::{CString, ToCStr}; use libc; + use kinds::Copy; use ptr; use result::*; use string::String; @@ -262,6 +266,8 @@ 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 d43a7a66c5b..dc212e7cab3 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -231,6 +231,7 @@ 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}; use option::Option; @@ -420,6 +421,8 @@ 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 @@ -1560,6 +1563,8 @@ 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. @@ -1682,6 +1687,8 @@ 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. pub enum FileAccess { @@ -1693,6 +1700,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)] pub enum FileType { @@ -1715,6 +1724,8 @@ 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`. /// @@ -1766,6 +1777,8 @@ 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 @@ -1795,6 +1808,8 @@ 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."] @@ -1889,6 +1904,8 @@ bitflags! { } } +impl Copy for FilePermission {} + impl Default for FilePermission { #[inline] fn default() -> FilePermission { FilePermission::empty() } diff --git a/src/libstd/io/net/addrinfo.rs b/src/libstd/io/net/addrinfo.rs index fea8372733c..fc81ab7b57a 100644 --- a/src/libstd/io/net/addrinfo.rs +++ b/src/libstd/io/net/addrinfo.rs @@ -22,6 +22,7 @@ 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; @@ -32,6 +33,8 @@ 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. /// @@ -46,12 +49,16 @@ pub enum Flag { V4Mapped, } +impl Copy for Flag {} + /// A transport protocol associated with either a hint or a return value of /// `lookup` 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. /// @@ -64,6 +71,8 @@ pub struct Hint { pub flags: uint, } +impl Copy for Hint {} + pub struct Info { pub address: SocketAddr, pub family: uint, @@ -72,6 +81,8 @@ 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 3fa6f4a6091..f59dd37c0da 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -18,6 +18,7 @@ pub use self::IpAddr::*; use fmt; +use kinds::Copy; use io::{mod, IoResult, IoError}; use io::net; use iter::{Iterator, IteratorExt}; @@ -36,6 +37,8 @@ pub enum IpAddr { 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 { @@ -67,6 +70,8 @@ pub struct SocketAddr { 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 61ebfb06c71..c46a6e82e44 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -480,6 +480,8 @@ 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)] @@ -491,6 +493,8 @@ 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 e78bd1dd33f..faa52226a03 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -83,6 +83,8 @@ impl<R: Buffer> Buffer for LimitReader<R> { /// A `Writer` which ignores bytes written to it, like /dev/null. pub struct NullWriter; +impl Copy for NullWriter {} + impl Writer for NullWriter { #[inline] fn write(&mut self, _buf: &[u8]) -> io::IoResult<()> { Ok(()) } @@ -91,6 +93,8 @@ impl Writer for NullWriter { /// A `Reader` which returns an infinite stream of 0 bytes, like /dev/zero. pub struct ZeroReader; +impl Copy for ZeroReader {} + impl Reader for ZeroReader { #[inline] fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { @@ -111,6 +115,8 @@ impl Buffer for ZeroReader { /// A `Reader` which is always at EOF, like /dev/null. pub struct NullReader; +impl Copy for NullReader {} + impl Reader for NullReader { #[inline] fn read(&mut self, _buf: &mut [u8]) -> io::IoResult<uint> { diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index c87f40f351b..1c9826ff5ac 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -18,6 +18,7 @@ pub use self::SignFormat::*; use char; use char::Char; +use kinds::Copy; use num; use num::{Int, Float, FPNaN, FPInfinite, ToPrimitive}; use slice::{SlicePrelude, CloneSliceAllocPrelude}; @@ -38,6 +39,8 @@ pub enum ExponentFormat { ExpBin, } +impl Copy for ExponentFormat {} + /// The number of digits used for emitting the fractional part of a number, if /// any. pub enum SignificantDigits { @@ -55,6 +58,8 @@ pub enum SignificantDigits { DigExact(uint) } +impl Copy for SignificantDigits {} + /// How to emit the sign of a number. pub enum SignFormat { /// No sign will be printed. The exponent sign will also be emitted. @@ -67,25 +72,33 @@ pub enum SignFormat { SignAll, } -/// 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()`. -/// -/// # Arguments -/// -/// - `num` - The number to convert. Accepts any number that -/// implements the numeric traits. -/// - `radix` - Base to use. Accepts only the values 2-36. -/// - `sign` - How to emit the sign. Options are: -/// - `SignNone`: No sign at all. Basically emits `abs(num)`. -/// - `SignNeg`: Only `-` on negative values. -/// - `SignAll`: Both `+` on positive, and `-` on negative numbers. -/// - `f` - a callback which will be invoked for each ascii character -/// which composes the string representation of this integer -/// -/// # Panics -/// -/// - Panics if `radix` < 2 or `radix` > 36. +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()`. + * + * # Arguments + * - `num` - The number to convert. Accepts any number that + * implements the numeric traits. + * - `radix` - Base to use. Accepts only the values 2-36. + * - `sign` - How to emit the sign. Options are: + * - `SignNone`: No sign at all. Basically emits `abs(num)`. + * - `SignNeg`: Only `-` on negative values. + * - `SignAll`: Both `+` on positive, and `-` on negative numbers. + * - `f` - a callback which will be invoked for each ascii character + * which composes the string representation of this integer + * + * # Return value + * A tuple containing the byte vector, and a boolean flag indicating + * whether it represents a special value like `inf`, `-inf`, `NaN` or not. + * It returns a tuple because there can be ambiguity between a special value + * and a number representation at higher bases. + * + * # Failure + * - Fails if `radix` < 2 or `radix` > 36. + */ fn int_to_str_bytes_common<T: Int>(num: T, radix: uint, sign: SignFormat, f: |u8|) { assert!(2 <= radix && radix <= 36); diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 2b904acb565..f298ec74f6a 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -36,6 +36,7 @@ use error::{FromError, Error}; use fmt; use io::{IoResult, IoError}; use iter::{Iterator, IteratorExt}; +use kinds::Copy; use libc::{c_void, c_int}; use libc; use boxed::Box; @@ -619,6 +620,8 @@ 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 @@ -1185,6 +1188,9 @@ pub struct MemoryMap { kind: MemoryMapKind, } +#[cfg(not(stage0))] +impl Copy for MemoryMap {} + /// Type of memory map pub enum MemoryMapKind { /// Virtual memory map. Usually used to change the permissions of a given @@ -1196,6 +1202,8 @@ pub enum MemoryMapKind { MapVirtual } +impl Copy for MemoryMapKind {} + /// Options the memory map is created with pub enum MapOption { /// The memory should be readable @@ -1219,6 +1227,8 @@ pub enum MapOption { MapNonStandardFlags(c_int), } +impl Copy for MapOption {} + /// Possible errors when creating a map. pub enum MapError { /// ## The following are POSIX-specific @@ -1264,6 +1274,8 @@ 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 b53e6b2a5e0..ea522536d22 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -22,6 +22,7 @@ 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}; @@ -985,6 +986,8 @@ pub enum PathPrefix { DiskPrefix } +impl Copy for PathPrefix {} + fn parse_prefix<'a>(mut path: &'a str) -> Option<PathPrefix> { if path.starts_with("\\\\") { // \\ diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index cc3c46f3610..a359fcf7a9f 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -225,6 +225,7 @@ 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}; @@ -245,7 +246,11 @@ pub mod reader; /// The standard RNG. This is designed to be efficient on the current /// platform. -pub struct StdRng { rng: IsaacWordRng } +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 86c3a1fdd32..7e6065129a3 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -13,6 +13,7 @@ #![experimental] use {fmt, i64}; +use kinds::Copy; use ops::{Add, Sub, Mul, Div, Neg}; use option::Option; use option::Option::{Some, None}; @@ -64,6 +65,8 @@ 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. |
