de-mode-ify infer and some parts of typeck
also, fix bug in the various lint passes that fn() was considered not suitable for the default mode
This commit is contained in:
@@ -250,7 +250,7 @@ impl<T: copy, E: copy> result<T, E> {
|
||||
* }
|
||||
*/
|
||||
fn map_vec<T,U:copy,V:copy>(
|
||||
ts: ~[T], op: fn(T) -> result<V,U>) -> result<~[V],U> {
|
||||
ts: &[T], op: fn(T) -> result<V,U>) -> result<~[V],U> {
|
||||
|
||||
let mut vs: ~[V] = ~[];
|
||||
vec::reserve(vs, vec::len(ts));
|
||||
@@ -284,7 +284,7 @@ fn map_opt<T,U:copy,V:copy>(
|
||||
* used in 'careful' code contexts where it is both appropriate and easy
|
||||
* to accommodate an error like the vectors being of different lengths.
|
||||
*/
|
||||
fn map_vec2<S,T,U:copy,V:copy>(ss: ~[S], ts: ~[T],
|
||||
fn map_vec2<S,T,U:copy,V:copy>(ss: &[S], ts: &[T],
|
||||
op: fn(S,T) -> result<V,U>) -> result<~[V],U> {
|
||||
|
||||
assert vec::same_length(ss, ts);
|
||||
@@ -307,7 +307,7 @@ fn map_vec2<S,T,U:copy,V:copy>(ss: ~[S], ts: ~[T],
|
||||
* error. This could be implemented using `map2()` but it is more efficient
|
||||
* on its own as no result vector is built.
|
||||
*/
|
||||
fn iter_vec2<S,T,U:copy>(ss: ~[S], ts: ~[T],
|
||||
fn iter_vec2<S,T,U:copy>(ss: &[S], ts: &[T],
|
||||
op: fn(S,T) -> result<(),U>) -> result<(),U> {
|
||||
|
||||
assert vec::same_length(ss, ts);
|
||||
|
||||
@@ -17,6 +17,7 @@ export capacity;
|
||||
export len;
|
||||
export from_fn;
|
||||
export from_elem;
|
||||
export from_slice;
|
||||
export build, build_sized;
|
||||
export to_mut;
|
||||
export from_mut;
|
||||
@@ -211,6 +212,11 @@ pure fn from_elem<T: copy>(n_elts: uint, t: T) -> ~[T] {
|
||||
return v;
|
||||
}
|
||||
|
||||
/// Creates a new unique vector with the same contents as the slice
|
||||
pure fn from_slice<T: copy>(t: &[T]) -> ~[T] {
|
||||
from_fn(t.len(), |i| t[i])
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a vector by calling a provided function with an argument
|
||||
* function that pushes an element to the back of a vector.
|
||||
|
||||
Reference in New Issue
Block a user