Skip to content

vec: grow_fn doesn't require Copy #4998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/libcore/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down Expand Up @@ -1936,6 +1937,11 @@ impl<T> OwnedVector<T> for ~[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] {
Expand All @@ -1946,7 +1952,6 @@ impl<T> Mutable for ~[T] {
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);
}

Expand All @@ -1961,11 +1966,6 @@ impl<T: Copy> OwnedCopyableVector<T> for ~[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);
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down