[rust-dev] A better type system

Matthew McPherrin mozilla at mcpherrin.ca
Mon Jun 2 13:09:10 PDT 2014


Isn't this MutableVector's mut_split_at
<http://doc.rust-lang.org/std/slice/trait.MutableVector.html#tymethod.mut_split_at>
that we already have?


On Mon, Jun 2, 2014 at 8:25 AM, Patrick Walton <pcwalton at mozilla.com> wrote:

> On 6/2/14 12:44 AM, Tommi wrote:
>
>> In my original post I stated that it feels like there's something wrong
>> with the language when it doesn't allow multiple mutable references to
>> the same data, but I didn't really explain why it feels like that. So, I
>> just want to add this simple example to help explain my position. It is
>> just plain obvious to everybody that the following code snippet is
>> memory-safe, but the compiler refuses to compile it due to "cannot
>> borrow `stuff[..]` as mutable more than once at a time":
>>
>> let mut stuff = [1, 2, 3];
>> let r1 = stuff.mut_slice_to(2);
>> let r2 = stuff.mut_slice_from(1);
>>
>
> I'd like to have a function that splits up a vector in that way. That
> should be doable in the standard library using some unsafe code under the
> hood.
>
> Patrick
>
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140602/7cd4c49a/attachment.html>


More information about the Rust-dev mailing list