With the removal of ~[T] vector building functions by #13588, it is now very difficult to construct ~[T] with a size known at runtime. Currently I opted for this replacement of std::slice::from_elem:
fn from_elem<T: Clone>(size: uint, el: T) -> ~[T]
{
use std::iter::Repeat;
Repeat::new(el).take(size).collect()
}
but it is unclear to me if this workaround is not merely an oversight. Is the intention to make dynamically sized ~[T] impossible to construct?
With the removal of
~[T]vector building functions by #13588, it is now very difficult to construct~[T]with a size known at runtime. Currently I opted for this replacement ofstd::slice::from_elem:but it is unclear to me if this workaround is not merely an oversight. Is the intention to make dynamically sized
~[T]impossible to construct?