@@ -156,7 +156,7 @@ use result::Result::{Ok, Err};
156156use slice;
157157use slice:: AsSlice ;
158158use clone:: Clone ;
159- use ops:: Deref ;
159+ use ops:: { Deref , FnOnce } ;
160160
161161// Note that this is not a lang item per se, but it has a hidden dependency on
162162// `Iterator`, which is one. The compiler assumes that the `next` method of
@@ -389,7 +389,7 @@ impl<T> Option<T> {
389389 /// ```
390390 #[ inline]
391391 #[ unstable = "waiting for conventions" ]
392- pub fn unwrap_or_else ( self , f : || -> T ) -> T {
392+ pub fn unwrap_or_else < F : FnOnce ( ) -> T > ( self , f : F ) -> T {
393393 match self {
394394 Some ( x) => x,
395395 None => f ( )
@@ -413,7 +413,7 @@ impl<T> Option<T> {
413413 /// ```
414414 #[ inline]
415415 #[ unstable = "waiting for unboxed closures" ]
416- pub fn map < U > ( self , f : | T | -> U ) -> Option < U > {
416+ pub fn map < U , F : FnOnce ( T ) -> U > ( self , f : F ) -> Option < U > {
417417 match self {
418418 Some ( x) => Some ( f ( x) ) ,
419419 None => None
@@ -433,7 +433,7 @@ impl<T> Option<T> {
433433 /// ```
434434 #[ inline]
435435 #[ unstable = "waiting for unboxed closures" ]
436- pub fn map_or < U > ( self , def : U , f: | T | -> U ) -> U {
436+ pub fn map_or < U , F : FnOnce ( T ) -> U > ( self , def : U , f : F ) -> U {
437437 match self {
438438 Some ( t) => f ( t) ,
439439 None => def
@@ -455,7 +455,7 @@ impl<T> Option<T> {
455455 /// ```
456456 #[ inline]
457457 #[ unstable = "waiting for unboxed closures" ]
458- pub fn map_or_else < U > ( self , def : || -> U , f : | T | -> U ) -> U {
458+ pub fn map_or_else < U , D : FnOnce ( ) -> U , F : FnOnce ( T ) -> U > ( self , def : D , f : F ) -> U {
459459 match self {
460460 Some ( t) => f ( t) ,
461461 None => def ( )
@@ -497,7 +497,7 @@ impl<T> Option<T> {
497497 /// ```
498498 #[ inline]
499499 #[ experimental]
500- pub fn ok_or_else < E > ( self , err : || -> E ) -> Result < T , E > {
500+ pub fn ok_or_else < E , F : FnOnce ( ) -> E > ( self , err : F ) -> Result < T , E > {
501501 match self {
502502 Some ( v) => Ok ( v) ,
503503 None => Err ( err ( ) ) ,
@@ -615,7 +615,7 @@ impl<T> Option<T> {
615615 /// ```
616616 #[ inline]
617617 #[ unstable = "waiting for unboxed closures" ]
618- pub fn and_then < U > ( self , f : | T | -> Option < U > ) -> Option < U > {
618+ pub fn and_then < U , F : FnOnce ( T ) -> Option < U > > ( self , f : F ) -> Option < U > {
619619 match self {
620620 Some ( x) => f ( x) ,
621621 None => None ,
@@ -667,7 +667,7 @@ impl<T> Option<T> {
667667 /// ```
668668 #[ inline]
669669 #[ unstable = "waiting for unboxed closures" ]
670- pub fn or_else ( self , f : || -> Option < T > ) -> Option < T > {
670+ pub fn or_else < F : FnOnce ( ) -> Option < T > > ( self , f : F ) -> Option < T > {
671671 match self {
672672 Some ( _) => self ,
673673 None => f ( )
0 commit comments