@@ -239,6 +239,7 @@ use slice::AsSlice;
239
239
use iter:: { Iterator , IteratorExt , DoubleEndedIterator , FromIterator , ExactSizeIterator } ;
240
240
use option:: Option ;
241
241
use option:: Option :: { None , Some } ;
242
+ use ops:: { FnMut , FnOnce } ;
242
243
243
244
/// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
244
245
///
@@ -466,7 +467,7 @@ impl<T, E> Result<T, E> {
466
467
/// ```
467
468
#[ inline]
468
469
#[ unstable = "waiting for unboxed closures" ]
469
- pub fn map < U > ( self , op : | T | -> U ) -> Result < U , E > {
470
+ pub fn map < U , F : FnOnce ( T ) -> U > ( self , op : F ) -> Result < U , E > {
470
471
match self {
471
472
Ok ( t) => Ok ( op ( t) ) ,
472
473
Err ( e) => Err ( e)
@@ -492,7 +493,7 @@ impl<T, E> Result<T, E> {
492
493
/// ```
493
494
#[ inline]
494
495
#[ unstable = "waiting for unboxed closures" ]
495
- pub fn map_err < F > ( self , op : | E | -> F ) -> Result < T , F > {
496
+ pub fn map_err < F , O : FnOnce ( E ) -> F > ( self , op : O ) -> Result < T , F > {
496
497
match self {
497
498
Ok ( t) => Ok ( t) ,
498
499
Err ( e) => Err ( op ( e) )
@@ -612,7 +613,7 @@ impl<T, E> Result<T, E> {
612
613
/// ```
613
614
#[ inline]
614
615
#[ unstable = "waiting for unboxed closures" ]
615
- pub fn and_then < U > ( self , op : | T | -> Result < U , E > ) -> Result < U , E > {
616
+ pub fn and_then < U , F : FnOnce ( T ) -> Result < U , E > > ( self , op : F ) -> Result < U , E > {
616
617
match self {
617
618
Ok ( t) => op ( t) ,
618
619
Err ( e) => Err ( e) ,
@@ -666,7 +667,7 @@ impl<T, E> Result<T, E> {
666
667
/// ```
667
668
#[ inline]
668
669
#[ unstable = "waiting for unboxed closures" ]
669
- pub fn or_else < F > ( self , op : | E | -> Result < T , F > ) -> Result < T , F > {
670
+ pub fn or_else < F , O : FnOnce ( E ) -> Result < T , F > > ( self , op : O ) -> Result < T , F > {
670
671
match self {
671
672
Ok ( t) => Ok ( t) ,
672
673
Err ( e) => op ( e) ,
@@ -708,7 +709,7 @@ impl<T, E> Result<T, E> {
708
709
/// ```
709
710
#[ inline]
710
711
#[ unstable = "waiting for conventions" ]
711
- pub fn unwrap_or_else ( self , op : | E | -> T ) -> T {
712
+ pub fn unwrap_or_else < F : FnOnce ( E ) -> T > ( self , op : F ) -> T {
712
713
match self {
713
714
Ok ( t) => t,
714
715
Err ( e) => op ( e)
@@ -904,10 +905,11 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
904
905
pub fn fold < T ,
905
906
V ,
906
907
E ,
908
+ F : FnMut ( V , T ) -> V ,
907
909
Iter : Iterator < Result < T , E > > > (
908
910
mut iterator : Iter ,
909
911
mut init : V ,
910
- f : | V , T | -> V )
912
+ mut f : F )
911
913
-> Result < V , E > {
912
914
for t in iterator {
913
915
match t {
0 commit comments