~~~~
trait Num {
- static pure fn from_int(n: int) -> self;
+ static pure fn from_int(n: int) -> Self;
}
impl float: Num {
static pure fn from_int(n: int) -> float { n as float }
# do task::spawn_unlinked {
([1, 2, 3, 4])[0];
-(['x', 'y'])[1] = 'z';
(["a", "b"])[10]; // fails
# }
An example of three different swap expressions:
~~~~~~~~
-# let mut x = &[0];
-# let mut a = &[0];
+# let mut x = &mut [0];
+# let mut a = &mut [0];
# let i = 0;
# let y = {mut z: 0};
# let b = {mut c: 0};
An example of a copy expression:
~~~~
-fn mutate(vec: ~[int]) {
+fn mutate(mut vec: ~[int]) {
vec[0] = 10;
}
other at all, using `task::spawn_unlinked` for _isolated failure_.
~~~
-# fn random() -> int { 100 }
-# fn sleep_for(i: int) { for i.times { task::yield() } }
+# fn random() -> uint { 100 }
+# fn sleep_for(i: uint) { for i.times { task::yield() } }
# do task::try::<()> {
let (time1, time2) = (random(), random());
do task::spawn_unlinked {