actually that was what I was expected, sorry I'm not very confortable with slices yet. It should not allocate, indeed, there is no reason. Python doesn't allocate but the way it handle items, it doesn't really behave like rust's slices
Anyway, I fully back the [4160] change request :) ----- Gaetan 2013/11/20 Huon Wilson <[email protected]> > On 20/11/13 21:03, Gaetan wrote: > > Hello > > I'd like to know if you think it could be feasible to have a Python-like > syntax for indices in array and vector? > > I find it so obvious and practical. > > let i = ~[1, 2, 3, 4, 5] > > i[1] returns a the second item ("2") > i[1:] returns ~[2, 3, 4, 5] > i[:-2] return ~[1, 2, 3, 4] > i[-2] returns ~[4, 5] > i[1,-1] returns ~[2, 3, 4] > > Thanks ! > > ----- > Gaetan > > > > _______________________________________________ > Rust-dev mailing > [email protected]https://mail.mozilla.org/listinfo/rust-dev > > > > This has been proposed in #4160, and was even mentioned in Niko's recent > "Treating vectors like any other container" blog post[1]; although, as > Daniel says, they would return slices (&[T]), not new allocations. > > [4160]: https://github.com/mozilla/rust/issues/4160 > [1]: > http://smallcultfollowing.com/babysteps/blog/2013/11/14/treating-vectors-like-any-other-container/ > > > Huon > > _______________________________________________ > 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
