Skip to content

Commit 043d022

Browse files
committed
auto merge of #6468 : gifnksm/rust/rposition-immutable, r=brson
`position` and `rposition` belonged to `ImmutableCopyableVector`, but they don't need the value is copyable.
2 parents d217174 + 4e1fac8 commit 043d022

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
@@ -2071,6 +2071,8 @@ pub trait ImmutableVector<'self, T> {
20712071
fn initn(&self, n: uint) -> &'self [T];
20722072
fn last(&self) -> &'self T;
20732073
fn last_opt(&self) -> Option<&'self T>;
2074+
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
2075+
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
20742076
#[cfg(stage0)]
20752077
fn each_reverse(&self, blk: &fn(&T) -> bool);
20762078
#[cfg(not(stage0))]
@@ -2138,6 +2140,30 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
21382140
#[inline]
21392141
fn last_opt(&self) -> Option<&'self T> { last_opt(*self) }
21402142

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

22322258
pub trait ImmutableEqVector<T:Eq> {
2233-
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
22342259
fn position_elem(&self, t: &T) -> Option<uint>;
2235-
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
22362260
fn rposition_elem(&self, t: &T) -> Option<uint>;
22372261
}
22382262

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

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

0 commit comments

Comments
 (0)