1+ use crate :: marker:: Destruct ;
12use crate :: { convert, ops} ;
23
34/// Used to tell an operation whether it should exit early or go on as usual.
@@ -185,7 +186,11 @@ impl<B, C> ControlFlow<B, C> {
185186 /// ```
186187 #[ inline]
187188 #[ stable( feature = "control_flow_enum" , since = "1.83.0" ) ]
188- pub fn break_value ( self ) -> Option < B > {
189+ #[ rustc_const_unstable( feature = "const_control_flow" , issue = "148739" ) ]
190+ pub const fn break_value ( self ) -> Option < B >
191+ where
192+ Self : [ const ] Destruct ,
193+ {
189194 match self {
190195 ControlFlow :: Continue ( ..) => None ,
191196 ControlFlow :: Break ( x) => Some ( x) ,
@@ -271,7 +276,11 @@ impl<B, C> ControlFlow<B, C> {
271276 /// to the break value in case it exists.
272277 #[ inline]
273278 #[ stable( feature = "control_flow_enum" , since = "1.83.0" ) ]
274- pub fn map_break < T > ( self , f : impl FnOnce ( B ) -> T ) -> ControlFlow < T , C > {
279+ #[ rustc_const_unstable( feature = "const_control_flow" , issue = "148739" ) ]
280+ pub const fn map_break< T , F > ( self , f : F ) -> ControlFlow < T , C >
281+ where
282+ F : [ const ] FnOnce ( B ) -> T + [ const ] Destruct ,
283+ {
275284 match self {
276285 ControlFlow :: Continue ( x ) => ControlFlow :: Continue ( x ) ,
277286 ControlFlow :: Break ( x ) => ControlFlow :: Break ( f ( x ) ) ,
@@ -291,7 +300,11 @@ impl<B, C> ControlFlow<B, C> {
291300 /// ```
292301 #[ inline ]
293302 #[ stable ( feature = "control_flow_enum" , since = "1.83.0" ) ]
294- pub fn continue_value ( self ) -> Option < C > {
303+ #[ rustc_const_unstable ( feature = "const_control_flow" , issue = "148739" ) ]
304+ pub const fn continue_value ( self ) -> Option < C >
305+ where
306+ Self : [ const ] Destruct ,
307+ {
295308 match self {
296309 ControlFlow :: Continue ( x ) => Some ( x ) ,
297310 ControlFlow :: Break ( ..) => None ,
@@ -376,7 +389,11 @@ impl<B, C> ControlFlow<B, C> {
376389 /// to the continue value in case it exists.
377390 #[ inline]
378391 #[ stable( feature = "control_flow_enum" , since = "1.83.0" ) ]
379- pub fn map_continue < T > ( self , f : impl FnOnce ( C ) -> T ) -> ControlFlow < B , T > {
392+ #[ rustc_const_unstable( feature = "const_control_flow" , issue = "148739" ) ]
393+ pub const fn map_continue < T , F > ( self , f : F ) -> ControlFlow < B , T >
394+ where
395+ F : [ const ] FnOnce ( C ) -> T + [ const ] Destruct ,
396+ {
380397 match self {
381398 ControlFlow :: Continue ( x ) => ControlFlow :: Continue ( f ( x ) ) ,
382399 ControlFlow :: Break ( x ) => ControlFlow :: Break ( x ) ,
0 commit comments