about summary refs log tree commit diff
path: root/src/libstd/list.rs
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-09-28 00:22:18 -0700
committerBrian Anderson <banderson@mozilla.com>2012-09-28 00:22:28 -0700
commitbc9efaad9c978f71bd7ac2c91efbc957e25d43fb (patch)
tree5a966292079cbd3cbe120e939da824f119fd61a8 /src/libstd/list.rs
parent467f2abdd8b676aed94364f09c8334b6627bd5b0 (diff)
downloadrust-bc9efaad9c978f71bd7ac2c91efbc957e25d43fb.tar.gz
rust-bc9efaad9c978f71bd7ac2c91efbc957e25d43fb.zip
std: Eliminate deprecated patterns
Diffstat (limited to 'src/libstd/list.rs')
-rw-r--r--src/libstd/list.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/libstd/list.rs b/src/libstd/list.rs
index d8f7edada6a..1568c6c099f 100644
--- a/src/libstd/list.rs
+++ b/src/libstd/list.rs
@@ -1,6 +1,5 @@
 //! A standard linked list
 #[warn(deprecated_mode)];
-#[forbid(deprecated_pattern)];
 
 use core::cmp::Eq;
 use core::option;
@@ -47,8 +46,8 @@ fn find<T: Copy>(ls: @List<T>, f: fn((&T)) -> bool) -> Option<T> {
     let mut ls = ls;
     loop {
         ls = match *ls {
-          Cons(hd, tl) => {
-            if f(&hd) { return Some(hd); }
+          Cons(ref hd, tl) => {
+            if f(hd) { return Some(*hd); }
             tl
           }
           Nil => return None
@@ -95,7 +94,7 @@ pure fn tail<T: Copy>(ls: @List<T>) -> @List<T> {
 /// Returns the first element of a list
 pure fn head<T: Copy>(ls: @List<T>) -> T {
     match *ls {
-      Cons(hd, _) => hd,
+      Cons(copy hd, _) => hd,
       // makes me sad
       _ => fail ~"head invoked on empty list"
     }
@@ -105,7 +104,7 @@ pure fn head<T: Copy>(ls: @List<T>) -> T {
 pure fn append<T: Copy>(l: @List<T>, m: @List<T>) -> @List<T> {
     match *l {
       Nil => return m,
-      Cons(x, xs) => {
+      Cons(copy x, xs) => {
         let rest = append(xs, m);
         return @Cons(x, rest);
       }
@@ -151,9 +150,9 @@ fn each<T>(l: @List<T>, f: fn((&T)) -> bool) {
 impl<T:Eq> List<T> : Eq {
     pure fn eq(other: &List<T>) -> bool {
         match self {
-            Cons(e0a, e1a) => {
+            Cons(ref e0a, e1a) => {
                 match (*other) {
-                    Cons(e0b, e1b) => e0a == e0b && e1a == e1b,
+                    Cons(ref e0b, e1b) => e0a == e0b && e1a == e1b,
                     _ => false
                 }
             }