Hi,

So, i am trying to get my head around slices in Rust, specifically how
being unique affects them.

In C i can do the following, and when i am done fiddling, the values
are in the struct.

struct foo{
int a[100];
int b[100];
 }

 struct foo f;
 int dumb_a = &f.a;
 int dumb_b = &f.b;


fiddle(dumb_a);
fiddle(dumb_b);


I am trying to figure out if this is possible in Rust with unique types:

fn main(){
let mut v = ~[1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,];

let mut part1 = v.view(0,5);
let mut part2 = vec::slice(v, 6 , 10);
let mut count = 0;
for 5.times{
io::println(fmt!("%?", part1[count]));
count = count + 1;
}
part1[2] = 3;
}


This code is giving me an error, and i am not sure how to devlace a
unique vector with mutable content.

Now apart from the fact that i am getting a compile error, would the
values of vector v be changed after the statement : part1[2] = 3; ????

Is this even legal?

What would happen if i sent my slice over a channel and fiddled with it?

Is that allowed?

Paul
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to