-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-trait-systemArea: Trait systemArea: Trait systemA-type-systemArea: Type systemArea: Type systemE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Description
The following code doesn't compile because map_
is assigned the wrong type.
trait vec_utils<T> {
fn map_<U:Copy>(x: &Self, f: &fn(&T) -> U) -> ~[U];
}
impl<T> vec_utils<T> for ~[T] {
fn map_<U:Copy>(x: &~[T], f: &fn(&T) -> U) -> ~[U] {
let mut r = ~[];
for x.iter().advance |elt| {
r.push(f(elt));
}
r
}
}
fn main() {
vec_utils::map_(&~[1,2,3], |&x| x+1);
}
There is a mistake in the type parameter handling.
Metadata
Metadata
Assignees
Labels
A-trait-systemArea: Trait systemArea: Trait systemA-type-systemArea: Type systemArea: Type systemE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.