From 30cefcbdfde6ff12c550914fede8180344d54857 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 14 Dec 2014 22:35:22 -0500 Subject: [PATCH] libcore: use `#[deriving(Copy)]` --- src/libcore/atomic.rs | 4 +--- src/libcore/cmp.rs | 6 ++--- src/libcore/fmt/mod.rs | 6 ++--- src/libcore/fmt/num.rs | 8 ++----- src/libcore/fmt/rt.rs | 20 +++++----------- src/libcore/intrinsics.rs | 9 ++------ src/libcore/iter.rs | 16 ++++--------- src/libcore/kinds.rs | 8 ++----- src/libcore/num/mod.rs | 4 +--- src/libcore/ops.rs | 48 +++++++++++++-------------------------- src/libcore/option.rs | 7 +----- src/libcore/raw.rs | 6 ++--- src/libcore/result.rs | 6 +---- src/libcore/simd.rs | 43 ++++++++--------------------------- src/libcore/slice.rs | 4 +--- src/libcore/str.rs | 13 ++++------- 16 files changed, 57 insertions(+), 151 deletions(-) diff --git a/src/libcore/atomic.rs b/src/libcore/atomic.rs index bb2fed19e2a..f6bc4dbde38 100644 --- a/src/libcore/atomic.rs +++ b/src/libcore/atomic.rs @@ -16,7 +16,6 @@ pub use self::Ordering::*; use intrinsics; use cell::UnsafeCell; -use kinds::Copy; /// A boolean type which can be safely shared between threads. #[stable] @@ -53,6 +52,7 @@ pub struct AtomicPtr { /// Rust's memory orderings are [the same as /// C++'s](http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync). #[stable] +#[deriving(Copy)] pub enum Ordering { /// No ordering constraints, only atomic operations. #[stable] @@ -77,8 +77,6 @@ pub enum Ordering { SeqCst, } -impl Copy for Ordering {} - /// An `AtomicBool` initialized to `false`. #[unstable = "may be renamed, pending conventions for static initalizers"] pub const INIT_ATOMIC_BOOL: AtomicBool = diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index af82e6a00f3..6e793be67e2 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -43,7 +43,7 @@ pub use self::Ordering::*; -use kinds::{Copy, Sized}; +use kinds::Sized; use option::Option::{mod, Some, None}; /// Trait for values that can be compared for equality and inequality. @@ -94,7 +94,7 @@ pub trait Eq for Sized?: PartialEq { } /// An ordering is, e.g, a result of a comparison between two values. -#[deriving(Clone, PartialEq, Show)] +#[deriving(Clone, Copy, PartialEq, Show)] #[stable] pub enum Ordering { /// An ordering where a compared value is less [than another]. @@ -105,8 +105,6 @@ pub enum Ordering { Greater = 1i, } -impl Copy for Ordering {} - impl Ordering { /// Reverse the `Ordering`, so that `Less` becomes `Greater` and /// vice versa. diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index cc940cd9e20..79fb11f3854 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -44,10 +44,9 @@ pub type Result = result::Result<(), Error>; /// occurred. Any extra information must be arranged to be transmitted through /// some other means. #[experimental = "core and I/O reconciliation may alter this definition"] +#[deriving(Copy)] pub struct Error; -impl Copy for Error {} - /// A collection of methods that are required to format a message into a stream. /// /// This trait is the type which this modules requires when formatting @@ -104,6 +103,7 @@ enum Void {} /// compile time it is ensured that the function and the value have the correct /// types, and then this struct is used to canonicalize arguments to one type. #[experimental = "implementation detail of the `format_args!` macro"] +#[deriving(Copy)] pub struct Argument<'a> { value: &'a Void, formatter: fn(&Void, &mut Formatter) -> Result, @@ -137,8 +137,6 @@ impl<'a> Argument<'a> { } } -impl<'a> Copy for Argument<'a> {} - impl<'a> Arguments<'a> { /// When using the format_args!() macro, this function is used to generate the /// Arguments structure. diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 13cfcacf8da..cd8f226172a 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -16,7 +16,6 @@ use fmt; use iter::DoubleEndedIteratorExt; -use kinds::Copy; use num::{Int, cast}; use slice::SliceExt; @@ -109,14 +108,12 @@ radix! { UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x, x @ 10 ... 15 => b'A' + (x - 10) } /// A radix with in the range of `2..36`. -#[deriving(Clone, PartialEq)] +#[deriving(Clone, Copy, PartialEq)] #[unstable = "may be renamed or move to a different module"] pub struct Radix { base: u8, } -impl Copy for Radix {} - impl Radix { fn new(base: u8) -> Radix { assert!(2 <= base && base <= 36, "the base must be in the range of 2..36: {}", base); @@ -137,10 +134,9 @@ impl GenericRadix for Radix { /// A helper type for formatting radixes. #[unstable = "may be renamed or move to a different module"] +#[deriving(Copy)] pub struct RadixFmt(T, R); -impl Copy for RadixFmt where T: Copy, R: Copy {} - /// Constructs a radix formatter in the range of `2..36`. /// /// # Example diff --git a/src/libcore/fmt/rt.rs b/src/libcore/fmt/rt.rs index 748bd0bc4bd..35dd0390f30 100644 --- a/src/libcore/fmt/rt.rs +++ b/src/libcore/fmt/rt.rs @@ -20,17 +20,16 @@ pub use self::Alignment::*; pub use self::Count::*; pub use self::Position::*; pub use self::Flag::*; -use kinds::Copy; #[doc(hidden)] +#[deriving(Copy)] pub struct Argument<'a> { pub position: Position, pub format: FormatSpec, } -impl<'a> Copy for Argument<'a> {} - #[doc(hidden)] +#[deriving(Copy)] pub struct FormatSpec { pub fill: char, pub align: Alignment, @@ -39,10 +38,8 @@ pub struct FormatSpec { pub width: Count, } -impl Copy for FormatSpec {} - /// Possible alignments that can be requested as part of a formatting directive. -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] pub enum Alignment { /// Indication that contents should be left-aligned. AlignLeft, @@ -54,27 +51,24 @@ pub enum Alignment { AlignUnknown, } -impl Copy for Alignment {} - #[doc(hidden)] +#[deriving(Copy)] pub enum Count { CountIs(uint), CountIsParam(uint), CountIsNextParam, CountImplied, } -impl Copy for Count {} - #[doc(hidden)] +#[deriving(Copy)] pub enum Position { ArgumentNext, ArgumentIs(uint) } -impl Copy for Position {} - /// Flags which can be passed to formatting via a directive. /// /// These flags are discovered through the `flags` field of the `Formatter` /// structure. The flag in that structure is a union of these flags into a /// `uint` where each flag's discriminant is the corresponding bit. +#[deriving(Copy)] pub enum Flag { /// A flag which enables number formatting to always print the sign of a /// number. @@ -89,5 +83,3 @@ pub enum Flag { /// being aware of the sign to be printed. FlagSignAwareZeroPad, } - -impl Copy for Flag {} diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index e2afee9905d..d8f103fa0f3 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -42,11 +42,10 @@ #![experimental] #![allow(missing_docs)] -use kinds::Copy; - pub type GlueFn = extern "Rust" fn(*const i8); #[lang="ty_desc"] +#[deriving(Copy)] pub struct TyDesc { // sizeof(T) pub size: uint, @@ -61,8 +60,6 @@ pub struct TyDesc { pub name: &'static str, } -impl Copy for TyDesc {} - extern "rust-intrinsic" { // NB: These intrinsics take unsafe pointers because they mutate aliased @@ -540,13 +537,11 @@ extern "rust-intrinsic" { /// `TypeId` represents a globally unique identifier for a type #[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and // middle/lang_items.rs -#[deriving(Clone, PartialEq, Eq, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Show)] pub struct TypeId { t: u64, } -impl Copy for TypeId {} - impl TypeId { /// Returns the `TypeId` of the type this generic function has been instantiated with pub fn of() -> TypeId { diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index de5c0defb1a..1f83aad9c7c 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -59,7 +59,6 @@ pub use self::MinMaxResult::*; use clone::Clone; use cmp; use cmp::Ord; -use kinds::Copy; use mem; use num::{ToPrimitive, Int}; use ops::{Add, Deref, FnMut}; @@ -1168,7 +1167,7 @@ impl CloneIteratorExt for I where I: Iterator + Clone { } /// An iterator that repeats endlessly -#[deriving(Clone)] +#[deriving(Clone, Copy)] #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[stable] pub struct Cycle { @@ -1176,8 +1175,6 @@ pub struct Cycle { iter: T, } -impl Copy for Cycle {} - impl> Iterator for Cycle { #[inline] fn next(&mut self) -> Option { @@ -1635,13 +1632,12 @@ impl> RandomAccessIterator<(uint, A)> for Enumerat /// An iterator with a `peek()` that returns an optional reference to the next element. #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[stable] +#[deriving(Copy)] pub struct Peekable { iter: T, peeked: Option, } -impl Copy for Peekable {} - impl> Iterator for Peekable { #[inline] fn next(&mut self) -> Option { @@ -2267,7 +2263,7 @@ impl Iterator for Unfold where F: FnMut(&mut St) -> Optio /// An infinite iterator starting at `start` and advancing by `step` with each /// iteration -#[deriving(Clone)] +#[deriving(Clone, Copy)] #[unstable = "may be renamed"] pub struct Counter { /// The current state the counter is at (next value to be yielded) @@ -2276,8 +2272,6 @@ pub struct Counter { step: A, } -impl Copy for Counter {} - /// Creates a new counter with the specified start/step #[inline] #[unstable = "may be renamed"] @@ -2301,7 +2295,7 @@ impl + Clone> Iterator for Counter { } /// An iterator over the range [start, stop) -#[deriving(Clone)] +#[deriving(Clone, Copy)] #[unstable = "may be refactored due to numerics reform or ops reform"] pub struct Range { state: A, @@ -2309,8 +2303,6 @@ pub struct Range { one: A, } -impl Copy for Range {} - /// Returns an iterator over the given range [start, stop) (that is, starting /// at start (inclusive), and ending at stop (exclusive)). /// diff --git a/src/libcore/kinds.rs b/src/libcore/kinds.rs index 69f65e23389..93fd3f1b9f1 100644 --- a/src/libcore/kinds.rs +++ b/src/libcore/kinds.rs @@ -225,11 +225,9 @@ pub mod marker { /// For more information about variance, refer to this Wikipedia /// article . #[lang="covariant_lifetime"] - #[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)] + #[deriving(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct CovariantLifetime<'a>; - impl<'a> Copy for CovariantLifetime<'a> {} - /// As `ContravariantType`, but for lifetime parameters. Using /// `ContravariantLifetime<'a>` indicates that it is ok to /// substitute a *shorter* lifetime for `'a` than the one you @@ -243,11 +241,9 @@ pub mod marker { /// For more information about variance, refer to this Wikipedia /// article . #[lang="contravariant_lifetime"] - #[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)] + #[deriving(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct ContravariantLifetime<'a>; - impl<'a> Copy for ContravariantLifetime<'a> {} - /// As `InvariantType`, but for lifetime parameters. Using /// `InvariantLifetime<'a>` indicates that it is not ok to /// substitute any other lifetime for `'a` besides its original diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index fcb2ca93054..b4f867b4bb4 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1225,7 +1225,7 @@ impl_num_cast! { f32, to_f32 } impl_num_cast! { f64, to_f64 } /// Used for representing the classification of floating point numbers -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] #[unstable = "may be renamed"] pub enum FPCategory { /// "Not a Number", often obtained by dividing by zero @@ -1240,8 +1240,6 @@ pub enum FPCategory { FPNormal, } -impl Copy for FPCategory {} - /// A built-in floating point number. // FIXME(#5527): In a future version of Rust, many of these functions will // become constants. diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 0090da3cdad..6e4beb2356e 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -88,10 +88,9 @@ pub trait Drop { /// calling `add`, and therefore, `main` prints `Adding!`. /// /// ```rust +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Add for Foo { /// fn add(&self, _rhs: &Foo) -> Foo { /// println!("Adding!"); @@ -170,10 +169,9 @@ add_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } /// calling `sub`, and therefore, `main` prints `Subtracting!`. /// /// ```rust +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Sub for Foo { /// fn sub(&self, _rhs: &Foo) -> Foo { /// println!("Subtracting!"); @@ -252,10 +250,9 @@ sub_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } /// calling `mul`, and therefore, `main` prints `Multiplying!`. /// /// ```rust +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Mul for Foo { /// fn mul(&self, _rhs: &Foo) -> Foo { /// println!("Multiplying!"); @@ -334,10 +331,9 @@ mul_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } /// calling `div`, and therefore, `main` prints `Dividing!`. /// /// ``` +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Div for Foo { /// fn div(&self, _rhs: &Foo) -> Foo { /// println!("Dividing!"); @@ -416,10 +412,9 @@ div_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } /// calling `rem`, and therefore, `main` prints `Remainder-ing!`. /// /// ``` +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Rem for Foo { /// fn rem(&self, _rhs: &Foo) -> Foo { /// println!("Remainder-ing!"); @@ -527,10 +522,9 @@ rem_float_impl! { f64, fmod } /// `neg`, and therefore, `main` prints `Negating!`. /// /// ``` +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Neg for Foo { /// fn neg(&self) -> Foo { /// println!("Negating!"); @@ -639,10 +633,9 @@ neg_uint_impl! { u64, i64 } /// `not`, and therefore, `main` prints `Not-ing!`. /// /// ``` +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Not for Foo { /// fn not(&self) -> Foo { /// println!("Not-ing!"); @@ -724,10 +717,9 @@ not_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// calling `bitand`, and therefore, `main` prints `Bitwise And-ing!`. /// /// ``` +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl BitAnd for Foo { /// fn bitand(&self, _rhs: &Foo) -> Foo { /// println!("Bitwise And-ing!"); @@ -806,10 +798,9 @@ bitand_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// calling `bitor`, and therefore, `main` prints `Bitwise Or-ing!`. /// /// ``` +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl BitOr for Foo { /// fn bitor(&self, _rhs: &Foo) -> Foo { /// println!("Bitwise Or-ing!"); @@ -888,10 +879,9 @@ bitor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// calling `bitxor`, and therefore, `main` prints `Bitwise Xor-ing!`. /// /// ``` +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl BitXor for Foo { /// fn bitxor(&self, _rhs: &Foo) -> Foo { /// println!("Bitwise Xor-ing!"); @@ -970,10 +960,9 @@ bitxor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// calling `shl`, and therefore, `main` prints `Shifting left!`. /// /// ``` +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Shl for Foo { /// fn shl(&self, _rhs: &Foo) -> Foo { /// println!("Shifting left!"); @@ -1056,10 +1045,9 @@ shl_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// calling `shr`, and therefore, `main` prints `Shifting right!`. /// /// ``` +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Shr for Foo { /// fn shr(&self, _rhs: &Foo) -> Foo { /// println!("Shifting right!"); @@ -1139,10 +1127,9 @@ shr_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// calling `index`, and therefore, `main` prints `Indexing!`. /// /// ``` +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Index for Foo { /// fn index<'a>(&'a self, _index: &Foo) -> &'a Foo { /// println!("Indexing!"); @@ -1169,10 +1156,9 @@ pub trait Index for Sized? { /// calling `index_mut`, and therefore, `main` prints `Indexing!`. /// /// ``` +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl IndexMut for Foo { /// fn index_mut<'a>(&'a mut self, _index: &Foo) -> &'a mut Foo { /// println!("Indexing!"); @@ -1199,10 +1185,9 @@ pub trait IndexMut for Sized? { /// calling `slice_to`, and therefore, `main` prints `Slicing!`. /// /// ```ignore +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl Slice for Foo { /// fn as_slice_<'a>(&'a self) -> &'a Foo { /// println!("Slicing!"); @@ -1247,10 +1232,9 @@ pub trait Slice for Sized? { /// calling `slice_from_mut`, and therefore, `main` prints `Slicing!`. /// /// ```ignore +/// #[deriving(Copy)] /// struct Foo; /// -/// impl Copy for Foo {} -/// /// impl SliceMut for Foo { /// fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Foo { /// println!("Slicing!"); diff --git a/src/libcore/option.rs b/src/libcore/option.rs index deb1cea1c0e..314b47fc647 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -149,7 +149,6 @@ use cmp::{Eq, Ord}; use default::Default; use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator}; use iter::{ExactSizeIterator}; -use kinds::Copy; use mem; use result::Result; use result::Result::{Ok, Err}; @@ -164,7 +163,7 @@ use ops::{Deref, FnOnce}; // which basically means it must be `Option`. /// The `Option` type. -#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show, Hash)] +#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Show, Hash)] #[stable] pub enum Option { /// No value @@ -920,7 +919,3 @@ impl> FromIterator> for Option { } } } - -#[stable] -impl Copy for Option {} - diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index be2f4e590a3..d70c96d8c16 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -33,25 +33,23 @@ impl Copy for Slice {} /// The representation of a Rust closure #[repr(C)] +#[deriving(Copy)] pub struct Closure { pub code: *mut (), pub env: *mut (), } -impl Copy for Closure {} - /// The representation of a Rust trait object. /// /// This struct does not have a `Repr` implementation /// because there is no way to refer to all trait objects generically. #[repr(C)] +#[deriving(Copy)] pub struct TraitObject { pub data: *mut (), pub vtable: *mut (), } -impl Copy for TraitObject {} - /// This trait is meant to map equivalences between raw structs and their /// corresponding rust values. pub trait Repr for Sized? { diff --git a/src/libcore/result.rs b/src/libcore/result.rs index e12666a2adf..00a2a3d5854 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -232,7 +232,6 @@ use self::Result::*; -use kinds::Copy; use std::fmt::Show; use slice; use slice::AsSlice; @@ -244,7 +243,7 @@ use ops::{FnMut, FnOnce}; /// `Result` is a type that represents either success (`Ok`) or failure (`Err`). /// /// See the [`std::result`](index.html) module documentation for details. -#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show, Hash)] +#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Show, Hash)] #[must_use] #[stable] pub enum Result { @@ -919,6 +918,3 @@ pub fn fold Copy for Result {} - diff --git a/src/libcore/simd.rs b/src/libcore/simd.rs index 252a24e3aa9..0b0e6ff95c6 100644 --- a/src/libcore/simd.rs +++ b/src/libcore/simd.rs @@ -37,93 +37,70 @@ #![allow(non_camel_case_types)] #![allow(missing_docs)] -use kinds::Copy; - #[experimental] #[simd] -#[deriving(Show)] +#[deriving(Copy, Show)] #[repr(C)] pub struct i8x16(pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8); -impl Copy for i8x16 {} - #[experimental] #[simd] -#[deriving(Show)] +#[deriving(Copy, Show)] #[repr(C)] pub struct i16x8(pub i16, pub i16, pub i16, pub i16, pub i16, pub i16, pub i16, pub i16); -impl Copy for i16x8 {} - #[experimental] #[simd] -#[deriving(Show)] +#[deriving(Copy, Show)] #[repr(C)] pub struct i32x4(pub i32, pub i32, pub i32, pub i32); -impl Copy for i32x4 {} - #[experimental] #[simd] -#[deriving(Show)] +#[deriving(Copy, Show)] #[repr(C)] pub struct i64x2(pub i64, pub i64); -impl Copy for i64x2 {} - #[experimental] #[simd] -#[deriving(Show)] +#[deriving(Copy, Show)] #[repr(C)] pub struct u8x16(pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8); -impl Copy for u8x16 {} - #[experimental] #[simd] -#[deriving(Show)] +#[deriving(Copy, Show)] #[repr(C)] pub struct u16x8(pub u16, pub u16, pub u16, pub u16, pub u16, pub u16, pub u16, pub u16); -impl Copy for u16x8 {} - #[experimental] #[simd] -#[deriving(Show)] +#[deriving(Copy, Show)] #[repr(C)] pub struct u32x4(pub u32, pub u32, pub u32, pub u32); -impl Copy for u32x4 {} - #[experimental] #[simd] -#[deriving(Show)] +#[deriving(Copy, Show)] #[repr(C)] pub struct u64x2(pub u64, pub u64); -impl Copy for u64x2 {} - #[experimental] #[simd] -#[deriving(Show)] +#[deriving(Copy, Show)] #[repr(C)] pub struct f32x4(pub f32, pub f32, pub f32, pub f32); -impl Copy for f32x4 {} - #[experimental] #[simd] -#[deriving(Show)] +#[deriving(Copy, Show)] #[repr(C)] pub struct f64x2(pub f64, pub f64); - -impl Copy for f64x2 {} - diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 2ee60955245..f5d117bca9f 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1229,7 +1229,7 @@ impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutChunks<'a, T> { /// index of the matching element. `NotFound` means the search /// succeeded, and the contained value is an index where a matching /// value could be inserted while maintaining sort order. -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] #[experimental = "needs review"] pub enum BinarySearchResult { /// The index of the found value. @@ -1238,8 +1238,6 @@ pub enum BinarySearchResult { NotFound(uint) } -impl Copy for BinarySearchResult {} - #[experimental = "needs review"] impl BinarySearchResult { /// Converts a `Found` to `Some`, `NotFound` to `None`. diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 8fe41c0bd89..a89a7970ae9 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -27,7 +27,7 @@ use default::Default; use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator}; use iter::{DoubleEndedIteratorExt, ExactSizeIterator}; use iter::range; -use kinds::{Copy, Sized}; +use kinds::Sized; use mem; use num::Int; use option::Option; @@ -165,13 +165,11 @@ Section: Iterators /// Iterator for the char (representing *Unicode Scalar Values*) of a string /// /// Created with the method `.chars()`. -#[deriving(Clone)] +#[deriving(Clone, Copy)] pub struct Chars<'a> { iter: slice::Items<'a, u8> } -impl<'a> Copy for Chars<'a> {} - // Return the initial codepoint accumulator for the first byte. // The first byte is special, only want bottom 5 bits for width 2, 4 bits // for width 3, and 3 bits for width 4 @@ -998,7 +996,7 @@ pub struct Utf16Items<'a> { iter: slice::Items<'a, u16> } /// The possibilities for values decoded from a `u16` stream. -#[deriving(PartialEq, Eq, Clone, Show)] +#[deriving(Copy, PartialEq, Eq, Clone, Show)] pub enum Utf16Item { /// A valid codepoint. ScalarValue(char), @@ -1006,8 +1004,6 @@ pub enum Utf16Item { LoneSurrogate(u16) } -impl Copy for Utf16Item {} - impl Utf16Item { /// Convert `self` to a `char`, taking `LoneSurrogate`s to the /// replacement character (U+FFFD). @@ -1144,6 +1140,7 @@ pub fn utf8_char_width(b: u8) -> uint { /// Struct that contains a `char` and the index of the first byte of /// the next `char` in a string. This can be used as a data structure /// for iterating over the UTF-8 bytes of a string. +#[deriving(Copy)] pub struct CharRange { /// Current `char` pub ch: char, @@ -1151,8 +1148,6 @@ pub struct CharRange { pub next: uint, } -impl Copy for CharRange {} - /// Mask of the value bits of a continuation byte const CONT_MASK: u8 = 0b0011_1111u8; /// Value of the tag bits (tag mask is !CONT_MASK) of a continuation byte