mozilla/rust — pull request #1695 by erickt (2012-01-28 18:07:08+00:00)
Title: Fleshing out vec functions

Added:

vec::position_from(v: [T], start: uint, end: uint, f: fn(T) -> bool) -> uint

vec::rposition(v: [T], f: fn(T) -> bool) -> uint
vec::rposition_from(v: [T], start: uint, end: uint, f: fn(T) -> bool) -> uint

vec::find(v: [T], f: fn(T) -> bool) -> T
vec::find_from(v: [T], start: uint, end: uint, f: fn(T) -> bool) -> T

vec::rfind(v: [T], f: fn(T) -> bool) -> T
vec::rfind_from(v: [T], start: uint, end: uint, f: fn(T) -> bool) -> T

vec::split(v: [T], f: fn(T) -> bool) -> [[T]]
vec::splitn(v: [T], n: uint, f: fn(T) -> bool) -> [[T]]

vec::rsplit(v: [T], f: fn(T) -> bool) -> [[T]]
vec::rsplitn(v: [T], n: uint, f: fn(T) -> bool) -> [[T]]

Renamed:

vec::position(v: [T], x: T) -> uint => vec::position_elt(v: [T], x: T) -> uint
vec::position_pred(v: [T], f: fn(T) -> bool) -> uint => vec::position(v: [T], f: fn(T) -> bool) -> uint

I'm not sure I'm crazy about keeping around `position_elt` though, since almost every other vec function just takes a block. What do you all think?