@@ -239,6 +239,7 @@ use slice::AsSlice;
239239use iter:: { Iterator , IteratorExt , DoubleEndedIterator , FromIterator , ExactSizeIterator } ;
240240use option:: Option ;
241241use option:: Option :: { None , Some } ;
242+ use ops:: { FnMut , FnOnce } ;
242243
243244/// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
244245///
@@ -466,7 +467,7 @@ impl<T, E> Result<T, E> {
466467 /// ```
467468 #[ inline]
468469 #[ 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 > {
470471 match self {
471472 Ok ( t) => Ok ( op ( t) ) ,
472473 Err ( e) => Err ( e)
@@ -492,7 +493,7 @@ impl<T, E> Result<T, E> {
492493 /// ```
493494 #[ inline]
494495 #[ 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 > {
496497 match self {
497498 Ok ( t) => Ok ( t) ,
498499 Err ( e) => Err ( op ( e) )
@@ -612,7 +613,7 @@ impl<T, E> Result<T, E> {
612613 /// ```
613614 #[ inline]
614615 #[ 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 > {
616617 match self {
617618 Ok ( t) => op ( t) ,
618619 Err ( e) => Err ( e) ,
@@ -666,7 +667,7 @@ impl<T, E> Result<T, E> {
666667 /// ```
667668 #[ inline]
668669 #[ 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 > {
670671 match self {
671672 Ok ( t) => Ok ( t) ,
672673 Err ( e) => op ( e) ,
@@ -708,7 +709,7 @@ impl<T, E> Result<T, E> {
708709 /// ```
709710 #[ inline]
710711 #[ 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 {
712713 match self {
713714 Ok ( t) => t,
714715 Err ( e) => op ( e)
@@ -904,10 +905,11 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
904905pub fn fold < T ,
905906 V ,
906907 E ,
908+ F : FnMut ( V , T ) -> V ,
907909 Iter : Iterator < Result < T , E > > > (
908910 mut iterator : Iter ,
909911 mut init : V ,
910- f : | V , T | -> V )
912+ mut f : F )
911913 -> Result < V , E > {
912914 for t in iterator {
913915 match t {
0 commit comments