]> git.proxmox.com Git - rustc.git/blobdiff - src/test/run-pass/class-impl-very-parameterized-trait.rs
Imported Upstream version 1.2.0+dfsg1
[rustc.git] / src / test / run-pass / class-impl-very-parameterized-trait.rs
index 629cf7c4ef77b344ee36e56dcee19ae32267b136..27a57a888591556955e86166cc56aa6d0140f28c 100644 (file)
 
 use std::cmp;
 
-#[derive(Show)]
+#[derive(Copy, Clone, Debug)]
 enum cat_type { tuxedo, tabby, tortoiseshell }
 
-impl Copy for cat_type {}
-
 impl cmp::PartialEq for cat_type {
     fn eq(&self, other: &cat_type) -> bool {
-        ((*self) as uint) == ((*other) as uint)
+        ((*self) as usize) == ((*other) as usize)
     }
     fn ne(&self, other: &cat_type) -> bool { !(*self).eq(other) }
 }
 
 // Very silly -- this just returns the value of the name field
-// for any int value that's less than the meows field
+// for any isize value that's less than the meows field
 
 // ok: T should be in scope when resolving the trait ref for map
 struct cat<T> {
     // Yes, you can have negative meows
-    meows : int,
+    meows : isize,
 
-    how_hungry : int,
+    how_hungry : isize,
     name : T,
 }
 
@@ -48,26 +46,26 @@ impl<T> cat<T> {
             return false;
         }
     }
-    fn len(&self) -> uint { self.meows as uint }
+    fn len(&self) -> usize { self.meows as usize }
     fn is_empty(&self) -> bool { self.meows == 0 }
     fn clear(&mut self) {}
-    fn contains_key(&self, k: &int) -> bool { *k <= self.meows }
+    fn contains_key(&self, k: &isize) -> bool { *k <= self.meows }
 
-    fn find(&self, k: &int) -> Option<&T> {
+    fn find(&self, k: &isize) -> Option<&T> {
         if *k <= self.meows {
             Some(&self.name)
         } else {
             None
         }
     }
-    fn insert(&mut self, k: int, _: T) -> bool {
+    fn insert(&mut self, k: isize, _: T) -> bool {
         self.meows += k;
         true
     }
 
-    fn find_mut(&mut self, _k: &int) -> Option<&mut T> { panic!() }
+    fn find_mut(&mut self, _k: &isize) -> Option<&mut T> { panic!() }
 
-    fn remove(&mut self, k: &int) -> bool {
+    fn remove(&mut self, k: &isize) -> bool {
         if self.find(k).is_some() {
             self.meows -= *k; true
         } else {
@@ -75,20 +73,20 @@ impl<T> cat<T> {
         }
     }
 
-    fn pop(&mut self, _k: &int) -> Option<T> { panic!() }
+    fn pop(&mut self, _k: &isize) -> Option<T> { panic!() }
 
-    fn swap(&mut self, _k: int, _v: T) -> Option<T> { panic!() }
+    fn swap(&mut self, _k: isize, _v: T) -> Option<T> { panic!() }
 }
 
 impl<T> cat<T> {
-    pub fn get(&self, k: &int) -> &T {
+    pub fn get(&self, k: &isize) -> &T {
         match self.find(k) {
           Some(v) => { v }
           None    => { panic!("epic fail"); }
         }
     }
 
-    pub fn new(in_x: int, in_y: int, in_name: T) -> cat<T> {
+    pub fn new(in_x: isize, in_y: isize, in_name: T) -> cat<T> {
         cat{meows: in_x, how_hungry: in_y, name: in_name }
     }
 }
@@ -105,11 +103,11 @@ impl<T> cat<T> {
 
 pub fn main() {
     let mut nyan: cat<String> = cat::new(0, 2, "nyan".to_string());
-    for _ in range(1u, 5) { nyan.speak(); }
-    assert!(*nyan.find(&1).unwrap() == "nyan".to_string());
+    for _ in 1_usize..5 { nyan.speak(); }
+    assert_eq!(*nyan.find(&1).unwrap(), "nyan".to_string());
     assert_eq!(nyan.find(&10), None);
     let mut spotty: cat<cat_type> = cat::new(2, 57, cat_type::tuxedo);
-    for _ in range(0u, 6) { spotty.speak(); }
+    for _ in 0_usize..6 { spotty.speak(); }
     assert_eq!(spotty.len(), 8);
     assert!((spotty.contains_key(&2)));
     assert_eq!(spotty.get(&3), &cat_type::tuxedo);