@@ -206,7 +206,7 @@ impl<T> Vec<T> {
206
206
#[ inline]
207
207
#[ unstable = "the naming is uncertain as well as this migrating to unboxed \
208
208
closures in the future"]
209
- pub fn from_fn ( length : uint , op: |uint| -> T ) -> Vec < T > {
209
+ pub fn from_fn < F > ( length : uint , mut op : F ) -> Vec < T > where F : FnMut ( uint ) -> T {
210
210
unsafe {
211
211
let mut xs = Vec :: with_capacity ( length) ;
212
212
while xs. len < length {
@@ -289,7 +289,7 @@ impl<T> Vec<T> {
289
289
/// ```
290
290
#[ inline]
291
291
#[ experimental]
292
- pub fn partition ( self , f: | & T | -> bool ) -> ( Vec < T > , Vec < T > ) {
292
+ pub fn partition < F > ( self , mut f : F ) -> ( Vec < T > , Vec < T > ) where F : FnMut ( & T ) -> bool {
293
293
let mut lefts = Vec :: new ( ) ;
294
294
let mut rights = Vec :: new ( ) ;
295
295
@@ -400,7 +400,7 @@ impl<T: Clone> Vec<T> {
400
400
/// assert_eq!(odd, vec![1i, 3]);
401
401
/// ```
402
402
#[ experimental]
403
- pub fn partitioned ( & self , f: | & T | -> bool ) -> ( Vec < T > , Vec < T > ) {
403
+ pub fn partitioned < F > ( & self , mut f : F ) -> ( Vec < T > , Vec < T > ) where F : FnMut ( & T ) -> bool {
404
404
let mut lefts = Vec :: new ( ) ;
405
405
let mut rights = Vec :: new ( ) ;
406
406
@@ -991,7 +991,7 @@ impl<T> Vec<T> {
991
991
/// assert_eq!(vec, vec![2, 4]);
992
992
/// ```
993
993
#[ unstable = "the closure argument may become an unboxed closure" ]
994
- pub fn retain ( & mut self , f: | & T | -> bool) {
994
+ pub fn retain < F > ( & mut self , mut f : F ) where F : FnMut ( & T ) -> bool {
995
995
let len = self . len ( ) ;
996
996
let mut del = 0 u;
997
997
{
@@ -1023,7 +1023,7 @@ impl<T> Vec<T> {
1023
1023
/// assert_eq!(vec, vec![0, 1, 0, 1, 2]);
1024
1024
/// ```
1025
1025
#[ unstable = "this function may be renamed or change to unboxed closures" ]
1026
- pub fn grow_fn ( & mut self , n : uint , f: | uint| -> T ) {
1026
+ pub fn grow_fn < F > ( & mut self , n : uint , mut f : F ) where F : FnMut ( uint ) -> T {
1027
1027
self . reserve ( n) ;
1028
1028
for i in range ( 0 u, n) {
1029
1029
self . push ( f ( i) ) ;
@@ -1570,7 +1570,7 @@ impl<T> Vec<T> {
1570
1570
/// let newtyped_bytes = bytes.map_in_place(|x| Newtype(x));
1571
1571
/// assert_eq!(newtyped_bytes.as_slice(), [Newtype(0x11), Newtype(0x22)].as_slice());
1572
1572
/// ```
1573
- pub fn map_in_place < U > ( self , f: | T | -> U ) -> Vec < U > {
1573
+ pub fn map_in_place < U , F > ( self , mut f : F ) -> Vec < U > where F : FnMut ( T ) -> U {
1574
1574
// FIXME: Assert statically that the types `T` and `U` have the same
1575
1575
// size.
1576
1576
assert ! ( mem:: size_of:: <T >( ) == mem:: size_of:: <U >( ) ) ;
0 commit comments