Skip to content

Commit c32a482

Browse files
author
Jorge Aparicio
committed
libcollections: use #[deriving(Copy)]
1 parent bd90b93 commit c32a482

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

src/libcollections/binary_heap.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@
2929
//! use std::collections::BinaryHeap;
3030
//! use std::uint;
3131
//!
32-
//! #[deriving(Eq, PartialEq)]
32+
//! #[deriving(Copy, Eq, PartialEq)]
3333
//! struct State {
3434
//! cost: uint,
3535
//! position: uint
3636
//! }
3737
//!
38-
//! impl Copy for State {}
39-
//!
4038
//! // The priority queue depends on `Ord`.
4139
//! // Explicitly implement the trait so the queue becomes a min-heap
4240
//! // instead of a max-heap.

src/libcollections/enum_set.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,12 @@ mod test {
301301

302302
use super::{EnumSet, CLike};
303303

304-
#[deriving(PartialEq, Show)]
304+
#[deriving(Copy, PartialEq, Show)]
305305
#[repr(uint)]
306306
enum Foo {
307307
A, B, C
308308
}
309309

310-
impl Copy for Foo {}
311-
312310
impl CLike for Foo {
313311
fn to_uint(&self) -> uint {
314312
*self as uint
@@ -507,6 +505,7 @@ mod test {
507505
#[should_fail]
508506
fn test_overflow() {
509507
#[allow(dead_code)]
508+
#[deriving(Copy)]
510509
#[repr(uint)]
511510
enum Bar {
512511
V00, V01, V02, V03, V04, V05, V06, V07, V08, V09,
@@ -518,8 +517,6 @@ mod test {
518517
V60, V61, V62, V63, V64, V65, V66, V67, V68, V69,
519518
}
520519

521-
impl Copy for Bar {}
522-
523520
impl CLike for Bar {
524521
fn to_uint(&self) -> uint {
525522
*self as uint

src/libcollections/slice.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ use alloc::boxed::Box;
9191
use core::borrow::{BorrowFrom, BorrowFromMut, ToOwned};
9292
use core::cmp;
9393
use core::iter::{range_step, MultiplicativeIterator};
94-
use core::kinds::{Copy, Sized};
94+
use core::kinds::Sized;
9595
use core::mem::size_of;
9696
use core::mem;
9797
use core::ops::FnMut;
@@ -177,18 +177,16 @@ impl ElementSwaps {
177177
}
178178
}
179179

180+
#[deriving(Copy)]
180181
enum Direction { Pos, Neg }
181182

182-
impl Copy for Direction {}
183-
184183
/// An `Index` and `Direction` together.
184+
#[deriving(Copy)]
185185
struct SizeDirection {
186186
size: uint,
187187
dir: Direction,
188188
}
189189

190-
impl Copy for SizeDirection {}
191-
192190
impl Iterator<(uint, uint)> for ElementSwaps {
193191
#[inline]
194192
fn next(&mut self) -> Option<(uint, uint)> {

src/libcore/hash/sip.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use default::Default;
3030
use super::{Hash, Hasher, Writer};
3131

3232
/// `SipState` computes a SipHash 2-4 hash over a stream of bytes.
33+
#[deriving(Copy)]
3334
pub struct SipState {
3435
k0: u64,
3536
k1: u64,
@@ -42,8 +43,6 @@ pub struct SipState {
4243
ntail: uint, // how many bytes in tail are valid
4344
}
4445

45-
impl Copy for SipState {}
46-
4746
// sadly, these macro definitions can't appear later,
4847
// because they're needed in the following defs;
4948
// this design could be improved.

0 commit comments

Comments
 (0)