Fair enough, but I hope that the Index trait overhaul is merged before the
ability to use slices like this is removed. To do otherwise would be
unpleasant.


On Sun, May 4, 2014 at 3:09 PM, Steven Fackler <[email protected]> wrote:

> That will be possible, but the Index trait needs to be overhauled first.
>
> Steven Fackler
>
>
> On Sun, May 4, 2014 at 3:01 PM, Brian Rogoff <[email protected]> wrote:
>
>> On Sat, May 3, 2014 at 2:27 AM, Artella Coding <
>> [email protected]> wrote:
>>
>>> Hi looking at https://github.com/rust-lang/rfcs/pull/59 , is it the
>>> case that the following replacement rules apply :
>>>
>>> 1) ~T is replaced by Box<T>
>>> 2) ~[T] is replaced by Vec<T>
>>>
>>> and what does little "box" (as opposed to Box<T>) do?
>>>
>>
>> I have some code that makes a matrix of nested slices that looks like
>> this (make_owned_slice is a helper fn)
>>
>> fn make_owned_slice<T:Clone>(n: uint, default: T) -> ~[T] {
>>     Vec::from_elem(n, default).as_slice().to_owned()
>> }
>>
>> fn make_matrix<T:Clone>(nrows: uint, ncols: uint, default: T) -> ~[~[T]] {
>>     make_owned_slice(nrows, make_owned_slice(ncols, default))
>> }
>>
>> Is that code going to become the following
>>
>> fn make_matrix<T:Clone>(nrows: uint, ncols: uint, default: T) ->
>> Vec<Vec<T>> {
>>     Vec::from_elem(nrows, Vec::from_elem(ncols, default))
>> }
>>
>> and will I be able to index matrices of Vec<Vec<T>> like matrix[i][j]?
>> Last time I checked vectors weren't indexable that way.
>>
>>
>>
>>
>>>
>>> When will these changes appear in the nightlies? I am using "rustc
>>> 0.11-pre-nightly (e97d4e6 2014-05-01 23:41:46 -0700)" and the changes don't
>>> seem to have appeared yet. Thanks
>>>
>>> _______________________________________________
>>> Rust-dev mailing list
>>> [email protected]
>>> https://mail.mozilla.org/listinfo/rust-dev
>>>
>>>
>>
>> _______________________________________________
>> Rust-dev mailing list
>> [email protected]
>> https://mail.mozilla.org/listinfo/rust-dev
>>
>>
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to