Skip to content

Commit 4e1fac8

Browse files
committed
Move position and rposition methods to ImmutableVector trait
1 parent 3aa1122 commit 4e1fac8

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/libcore/vec.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,6 +2069,8 @@ pub trait ImmutableVector<'self, T> {
20692069
fn initn(&self, n: uint) -> &'self [T];
20702070
fn last(&self) -> &'self T;
20712071
fn last_opt(&self) -> Option<&'self T>;
2072+
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
2073+
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
20722074
#[cfg(stage0)]
20732075
fn each_reverse(&self, blk: &fn(&T) -> bool);
20742076
#[cfg(not(stage0))]
@@ -2136,6 +2138,30 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
21362138
#[inline]
21372139
fn last_opt(&self) -> Option<&'self T> { last_opt(*self) }
21382140

2141+
/**
2142+
* Find the first index matching some predicate
2143+
*
2144+
* Apply function `f` to each element of `v`. When function `f` returns
2145+
* true then an option containing the index is returned. If `f` matches no
2146+
* elements then none is returned.
2147+
*/
2148+
#[inline]
2149+
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2150+
position(*self, f)
2151+
}
2152+
2153+
/**
2154+
* Find the last index matching some predicate
2155+
*
2156+
* Apply function `f` to each element of `v` in reverse order. When
2157+
* function `f` returns true then an option containing the index is
2158+
* returned. If `f` matches no elements then none is returned.
2159+
*/
2160+
#[inline]
2161+
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2162+
rposition(*self, f)
2163+
}
2164+
21392165
/// Iterates over a vector's elements in reverse.
21402166
#[inline]
21412167
#[cfg(stage0)]
@@ -2228,43 +2254,17 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
22282254
}
22292255

22302256
pub trait ImmutableEqVector<T:Eq> {
2231-
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
22322257
fn position_elem(&self, t: &T) -> Option<uint>;
2233-
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
22342258
fn rposition_elem(&self, t: &T) -> Option<uint>;
22352259
}
22362260

22372261
impl<'self,T:Eq> ImmutableEqVector<T> for &'self [T] {
2238-
/**
2239-
* Find the first index matching some predicate
2240-
*
2241-
* Apply function `f` to each element of `v`. When function `f` returns
2242-
* true then an option containing the index is returned. If `f` matches no
2243-
* elements then none is returned.
2244-
*/
2245-
#[inline]
2246-
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2247-
position(*self, f)
2248-
}
2249-
22502262
/// Find the first index containing a matching value
22512263
#[inline]
22522264
fn position_elem(&self, x: &T) -> Option<uint> {
22532265
position_elem(*self, x)
22542266
}
22552267

2256-
/**
2257-
* Find the last index matching some predicate
2258-
*
2259-
* Apply function `f` to each element of `v` in reverse order. When
2260-
* function `f` returns true then an option containing the index is
2261-
* returned. If `f` matches no elements then none is returned.
2262-
*/
2263-
#[inline]
2264-
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2265-
rposition(*self, f)
2266-
}
2267-
22682268
/// Find the last index containing a matching value
22692269
#[inline]
22702270
fn rposition_elem(&self, t: &T) -> Option<uint> {

0 commit comments

Comments
 (0)