I've tried to simulate that with iterators, but it seems I can still read
the buffer. This compiles without errors:
let mut buf = [0, ..1024];
let mut iter = buf.mut_iter();
let x = buf[0];
*iter.next().unwrap() = 2; // just to make sure I can mutate via the
iterator
On Wed, Jan 29, 2014 at 2:06 PM, Daniel Micay <[email protected]> wrote:
> On Wed, Jan 29, 2014 at 5:03 PM, Vadim <[email protected]> wrote:
> >
> > But maybe Rust type system could grow a new type of borrow that prevents
> all
> > object access while it is in scope, similarly to how iterators prevent
> > mutation of the container being iterated?
> >
> > Vadim
>
> An `&mut` borrow will prevent reads not through that borrow.
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev