vec: grow_fn doesn't require Copy
This commit is contained in:
parent
a6945f2a45
commit
6956e81c9b
@ -1865,6 +1865,7 @@ pub trait OwnedVector<T> {
|
||||
fn consume(self, f: fn(uint, v: T));
|
||||
fn filter(self, f: fn(t: &T) -> bool) -> ~[T];
|
||||
fn partition(self, f: pure fn(&T) -> bool) -> (~[T], ~[T]);
|
||||
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>);
|
||||
}
|
||||
|
||||
impl<T> OwnedVector<T> for ~[T] {
|
||||
@ -1936,6 +1937,11 @@ fn filter(self, f: fn(&T) -> bool) -> ~[T] {
|
||||
fn partition(self, f: fn(&T) -> bool) -> (~[T], ~[T]) {
|
||||
partition(self, f)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>) {
|
||||
grow_fn(self, n, op);
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Mutable for ~[T] {
|
||||
@ -1946,7 +1952,6 @@ fn clear(&mut self) { self.truncate(0) }
|
||||
pub trait OwnedCopyableVector<T: Copy> {
|
||||
fn push_all(&mut self, rhs: &[const T]);
|
||||
fn grow(&mut self, n: uint, initval: &T);
|
||||
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>);
|
||||
fn grow_set(&mut self, index: uint, initval: &T, val: T);
|
||||
}
|
||||
|
||||
@ -1961,11 +1966,6 @@ fn grow(&mut self, n: uint, initval: &T) {
|
||||
grow(self, n, initval);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>) {
|
||||
grow_fn(self, n, op);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn grow_set(&mut self, index: uint, initval: &T, val: T) {
|
||||
grow_set(self, index, initval, val);
|
||||
|
@ -100,7 +100,7 @@ fn grow<T>(nelts: uint, lo: uint, elts: &mut [Option<T>]) -> ~[Option<T>] {
|
||||
assert nelts == elts.len();
|
||||
let mut rv = ~[];
|
||||
|
||||
do vec::grow_fn(&mut rv, nelts + 1) |i| {
|
||||
do rv.grow_fn(nelts + 1) |i| {
|
||||
let mut element = None;
|
||||
element <-> elts[(lo + i) % nelts];
|
||||
element
|
||||
|
Loading…
Reference in New Issue
Block a user