I found rust last night and am pretty impressed by what I've read so far
but I have a question. In the tutorial you seem to switch between pointer
types quite a bit when I don't _think_ it is relevant. Here is an example:
fn draw_all<T: Drawable>(shapes: ~[T]) {
for shapes.each |shape| { shape.draw(); }
}
becomes
fn draw_all(shapes: &[@Drawable]) {
for shapes.each |shape| { shape.draw(); }
}
Is it relevant that shapes is owned above and borrowed below? If I read
the section above right then it is best to declare everything as borrowed
unless you need to do otherwise.
Also, now that I think about it, is it possible to define shapes as
&[&Drawable] and then call draw_all with a &[@Drawable]? I'm trying to
wrap my head around all this but intuitively I think of pointers as
downgrade-able. Is that right?
Nik
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev