On Fri, Jun 28, 2013 at 02:46:43PM -0700, Graydon Hoare wrote: > >Specificity is the cost of non-virtual dispatch. However, if it is > >truly undesirable in some cases, we can eventually permit you to > >return `~Iterator<int>`, once ~-objects work properly. > > This is interesting. I assume we'd want these to be Iterator<> cast > to &Iterator<>, no? But we can't really do that in a return value; > we'd have to return the Iterator and have the caller cast it to > &Iterator<>. ~-allocating here seems a bit much..
Yes, allocating is somewhat heavy handed, but I don't see any alternative if you want to hide the precise type of the iterator: even if you were going to store the result on the caller's stack frame, the caller would have to know how much space to allocate! Conceivably one could pass in an arena or something once those work. Otherwise, you need something like an internal iterator. But in the end I just don't see this as a big problem one way or the other. Niko _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
