mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-17 01:13:11 +00:00
RIMOV, round 11
Last bit of mut removal, manually cleaning up outliers
This commit is contained in:
parent
0336a8633f
commit
743c1c37e8
15
doc/rust.md
15
doc/rust.md
@ -1716,15 +1716,12 @@ vec_elems : [expr [',' expr]*] | [expr ',' ".." expr]
|
||||
|
||||
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
|
||||
@ -1746,7 +1743,7 @@ task in a _failing state_.
|
||||
# do task::spawn_unlinked {
|
||||
|
||||
([1, 2, 3, 4])[0];
|
||||
([mut 'x', 'y'])[1] = 'z';
|
||||
(['x', 'y'])[1] = 'z';
|
||||
(["a", "b"])[10]; // fails
|
||||
|
||||
# }
|
||||
@ -1909,8 +1906,8 @@ No allocation or destruction is entailed.
|
||||
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};
|
||||
@ -2005,11 +2002,11 @@ the unary copy operator is typically only used to cause an argument to a functio
|
||||
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
|
||||
|
||||
|
@ -1795,7 +1795,7 @@ Generic `type`, `struct`, and `enum` declarations follow the same pattern:
|
||||
type Set<T> = HashMap<T, ()>;
|
||||
|
||||
struct Stack<T> {
|
||||
elements: ~[mut T]
|
||||
elements: ~[T]
|
||||
}
|
||||
|
||||
enum Option<T> {
|
||||
|
@ -280,8 +280,12 @@ pub pure fn view<T>(v: &r/[T], start: uint, end: uint) -> &r/[T] {
|
||||
}
|
||||
|
||||
/// 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| {
|
||||
@ -2199,12 +2203,8 @@ pub mod bytes {
|
||||
* 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) }
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ fn empty_pointy() -> @pointy {
|
||||
mut g : fn~()->(){},
|
||||
|
||||
mut m : ~[],
|
||||
mut n : ~[mut],
|
||||
mut n : ~[],
|
||||
mut o : {x : 0, y : none}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
struct invariant {
|
||||
f: @[mut &int]
|
||||
f: @mut [&int]
|
||||
}
|
||||
|
||||
fn to_same_lifetime(bi: invariant/&r) {
|
||||
@ -25,4 +25,4 @@ fn to_longer_lifetime(bi: invariant/&r) -> invariant/&static {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user