Fallout from mut slices
This commit is contained in:
parent
4e2afb0052
commit
3bf405682d
27 changed files with 65 additions and 66 deletions
|
|
@ -52,7 +52,7 @@ fn rotate(x: &mut [i32]) {
|
|||
|
||||
fn next_permutation(perm: &mut [i32], count: &mut [i32]) {
|
||||
for i in range(1, perm.len()) {
|
||||
rotate(perm[mut ..i + 1]);
|
||||
rotate(perm.slice_to_mut(i + 1));
|
||||
let count_i = &mut count[i];
|
||||
if *count_i >= i as i32 {
|
||||
*count_i = 0;
|
||||
|
|
@ -131,7 +131,7 @@ impl Perm {
|
|||
|
||||
|
||||
fn reverse(tperm: &mut [i32], mut k: uint) {
|
||||
tperm[mut ..k].reverse()
|
||||
tperm.slice_to_mut(k).reverse()
|
||||
}
|
||||
|
||||
fn work(mut perm: Perm, n: uint, max: uint) -> (i32, i32) {
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ impl<'a, W: Writer> RepeatFasta<'a, W> {
|
|||
|
||||
copy_memory(buf.as_mut_slice(), alu);
|
||||
let buf_len = buf.len();
|
||||
copy_memory(buf[mut alu_len..buf_len],
|
||||
copy_memory(buf.slice_mut(alu_len, buf_len),
|
||||
alu[..LINE_LEN]);
|
||||
|
||||
let mut pos = 0;
|
||||
|
|
|
|||
|
|
@ -254,6 +254,6 @@ fn parallel<'a, I, T, F>(mut iter: I, f: F)
|
|||
fn main() {
|
||||
let mut data = read_to_end(&mut stdin_raw()).unwrap();
|
||||
let tables = &Tables::new();
|
||||
parallel(mut_dna_seqs(data[mut]), |&: seq| reverse_complement(seq, tables));
|
||||
parallel(mut_dna_seqs(data.as_mut_slice()), |&: seq| reverse_complement(seq, tables));
|
||||
stdout_raw().write(data.as_mut_slice()).unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
// Test range syntax - type errors.
|
||||
#![feature(slicing_syntax)]
|
||||
|
||||
pub fn main() {
|
||||
// Mixed types.
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
// Test range syntax - borrow errors.
|
||||
#![feature(slicing_syntax)]
|
||||
|
||||
pub fn main() {
|
||||
let r = {
|
||||
|
|
|
|||
|
|
@ -20,8 +20,4 @@ fn main() {
|
|||
x[Foo..]; //~ ERROR cannot take a slice of a value with type `Foo`
|
||||
x[..Foo]; //~ ERROR cannot take a slice of a value with type `Foo`
|
||||
x[Foo..Foo]; //~ ERROR cannot take a slice of a value with type `Foo`
|
||||
x[mut]; //~ ERROR cannot take a mutable slice of a value with type `Foo`
|
||||
x[mut Foo..]; //~ ERROR cannot take a mutable slice of a value with type `Foo`
|
||||
x[mut ..Foo]; //~ ERROR cannot take a mutable slice of a value with type `Foo`
|
||||
x[mut Foo..Foo]; //~ ERROR cannot take a mutable slice of a value with type `Foo`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,5 +15,6 @@
|
|||
fn main() {
|
||||
let x: &[int] = &[1, 2, 3, 4, 5];
|
||||
// Can't mutably slice an immutable slice
|
||||
let y = x[mut 2..4]; //~ ERROR cannot borrow
|
||||
let slice: &mut [int] = &mut [0, 1];
|
||||
x[2..4] = slice; //~ ERROR cannot borrow
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,4 @@ fn main() {
|
|||
let x: &[int] = &[1, 2, 3, 4, 5];
|
||||
// Immutable slices are not mutable.
|
||||
let y: &mut[_] = x[2..4]; //~ ERROR cannot borrow immutable dereference of `&`-pointer as mutabl
|
||||
|
||||
let x: &mut [int] = &mut [1, 2, 3, 4, 5];
|
||||
// Can't borrow mutably twice
|
||||
let y = x[mut 1..2];
|
||||
let y = x[mut 4..5]; //~ERROR cannot borrow
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
// Test range syntax.
|
||||
|
||||
#![feature(slicing_syntax)]
|
||||
|
||||
fn foo() -> int { 42 }
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue