2011-05-19 16:43:46 -07:00
|
|
|
use std;
|
|
|
|
import std::vec;
|
|
|
|
|
|
|
|
fn main() {
|
2011-06-15 12:17:51 +02:00
|
|
|
let vec[mutable int] v = [mutable 10, 20];
|
2011-05-19 16:43:46 -07:00
|
|
|
|
|
|
|
assert v.(0) == 10;
|
|
|
|
assert v.(1) == 20;
|
|
|
|
|
2011-06-15 12:17:51 +02:00
|
|
|
vec::reverse(v);
|
2011-05-19 16:43:46 -07:00
|
|
|
|
|
|
|
assert v.(0) == 20;
|
|
|
|
assert v.(1) == 10;
|
|
|
|
|
2011-06-15 12:17:51 +02:00
|
|
|
auto v2 = vec::reversed[int]([10, 20]);
|
2011-05-19 16:43:46 -07:00
|
|
|
|
2011-06-15 12:17:51 +02:00
|
|
|
assert v2.(0) == 20;
|
|
|
|
assert v2.(1) == 10;
|
2011-05-19 16:43:46 -07:00
|
|
|
|
|
|
|
v.(0) = 30;
|
|
|
|
|
2011-06-15 12:17:51 +02:00
|
|
|
assert v2.(0) == 20;
|
2011-05-19 16:43:46 -07:00
|
|
|
|
|
|
|
// Make sure they work with 0-length vectors too.
|
2011-06-15 12:17:51 +02:00
|
|
|
auto v4 = vec::reversed[int]([]);
|
2011-05-19 16:43:46 -07:00
|
|
|
|
2011-06-15 12:17:51 +02:00
|
|
|
let vec[mutable int] v3 = vec::empty_mut();
|
2011-05-19 16:43:46 -07:00
|
|
|
vec::reverse[int](v3);
|
|
|
|
}
|