A [_vector_](#vector-types) _expression_ is written by enclosing zero or
more comma-separated expressions of uniform type in square brackets.
-The keyword `mut` can be written after the opening bracket to
-indicate that the elements of the resulting vector may be mutated.
-When no mutability is specified, the vector is immutable.
~~~~
[1, 2, 3, 4];
["a", "b", "c", "d"];
[0, ..128]; // vector with 128 zeros
-[mut 0u8, 0u8, 0u8, 0u8];
+[0u8, 0u8, 0u8, 0u8];
~~~~
### Index expressions
# do task::spawn_unlinked {
([1, 2, 3, 4])[0];
-([mut 'x', 'y'])[1] = 'z';
+(['x', 'y'])[1] = 'z';
(["a", "b"])[10]; // fails
# }
An example of three different swap expressions:
~~~~~~~~
-# let mut x = &[mut 0];
-# let mut a = &[mut 0];
+# let mut x = &[0];
+# let mut a = &[0];
# let i = 0;
# let y = {mut z: 0};
# let b = {mut c: 0};
An example of a copy expression:
~~~~
-fn mutate(vec: ~[mut int]) {
+fn mutate(vec: ~[int]) {
vec[0] = 10;
}
-let v = ~[mut 1,2,3];
+let v = ~[1,2,3];
mutate(copy v); // Pass a copy
}
/// Return a slice that points into another slice.
+<<<<<<< HEAD
#[inline(always)]
pub pure fn mut_view<T>(v: &r/[mut T], start: uint, end: uint) -> &r/[mut T] {
+=======
+pub pure fn mut_view<T>(v: &mut r/[T], start: uint, end: uint) -> &mut r/[T] {
+>>>>>>> RIMOV, round 11
assert (start <= end);
assert (end <= len(v));
do as_mut_buf(v) |p, _len| {
* Copies `count` bytes from `src` to `dst`. The source and destination
* may overlap.
*/
-<<<<<<< HEAD
#[inline(always)]
- pub fn copy_memory(dst: &[mut u8], src: &[const u8], count: uint) {
-=======
pub fn copy_memory(dst: &mut [u8], src: &[const u8], count: uint) {
->>>>>>> RIMOV, round 5
// Bound checks are done at vec::raw::copy_memory.
unsafe { vec::raw::copy_memory(dst, src, count) }
}