@@ -4445,8 +4445,10 @@ impl<T> [T] {
44454445/// ``` 
44464446#[ inline]  
44474447    #[ stable( feature = "slice_take" ,  since = "CURRENT_RUSTC_VERSION" ) ]  
4448-     pub  fn  split_off_first < ' a > ( self :  & mut  & ' a  Self )  -> Option < & ' a  T >  { 
4449-         let  ( first,  rem)  = self . split_first ( ) ?; 
4448+     #[ rustc_const_unstable( feature = "const_split_off_first_last" ,  issue = "138539" ) ]  
4449+     pub  const  fn  split_off_first < ' a > ( self :  & mut  & ' a  Self )  -> Option < & ' a  T >  { 
4450+         // FIXME(const-hack): Use `?` when available in const instead of `let-else`. 
4451+         let  Some ( ( first,  rem) )  = self . split_first ( )  else  {  return  None  } ; 
44504452        * self  = rem; 
44514453        Some ( first) 
44524454    } 
@@ -4468,8 +4470,11 @@ impl<T> [T] {
44684470/// ``` 
44694471#[ inline]  
44704472    #[ stable( feature = "slice_take" ,  since = "CURRENT_RUSTC_VERSION" ) ]  
4471-     pub  fn  split_off_first_mut < ' a > ( self :  & mut  & ' a  mut  Self )  -> Option < & ' a  mut  T >  { 
4472-         let  ( first,  rem)  = mem:: take ( self ) . split_first_mut ( ) ?; 
4473+     #[ rustc_const_unstable( feature = "const_split_off_first_last" ,  issue = "138539" ) ]  
4474+     pub  const  fn  split_off_first_mut < ' a > ( self :  & mut  & ' a  mut  Self )  -> Option < & ' a  mut  T >  { 
4475+         // FIXME(const-hack): Use `mem::take` and `?` when available in const. 
4476+         // Original: `mem::take(self).split_first_mut()?` 
4477+         let  Some ( ( first,  rem) )  = mem:: replace ( self ,  & mut  [ ] ) . split_first_mut ( )  else  {  return  None  } ; 
44734478        * self  = rem; 
44744479        Some ( first) 
44754480    } 
@@ -4490,8 +4495,10 @@ impl<T> [T] {
44904495/// ``` 
44914496#[ inline]  
44924497    #[ stable( feature = "slice_take" ,  since = "CURRENT_RUSTC_VERSION" ) ]  
4493-     pub  fn  split_off_last < ' a > ( self :  & mut  & ' a  Self )  -> Option < & ' a  T >  { 
4494-         let  ( last,  rem)  = self . split_last ( ) ?; 
4498+     #[ rustc_const_unstable( feature = "const_split_off_first_last" ,  issue = "138539" ) ]  
4499+     pub  const  fn  split_off_last < ' a > ( self :  & mut  & ' a  Self )  -> Option < & ' a  T >  { 
4500+         // FIXME(const-hack): Use `?` when available in const instead of `let-else`. 
4501+         let  Some ( ( last,  rem) )  = self . split_last ( )  else  {  return  None  } ; 
44954502        * self  = rem; 
44964503        Some ( last) 
44974504    } 
@@ -4513,8 +4520,11 @@ impl<T> [T] {
45134520/// ``` 
45144521#[ inline]  
45154522    #[ stable( feature = "slice_take" ,  since = "CURRENT_RUSTC_VERSION" ) ]  
4516-     pub  fn  split_off_last_mut < ' a > ( self :  & mut  & ' a  mut  Self )  -> Option < & ' a  mut  T >  { 
4517-         let  ( last,  rem)  = mem:: take ( self ) . split_last_mut ( ) ?; 
4523+     #[ rustc_const_unstable( feature = "const_split_off_first_last" ,  issue = "138539" ) ]  
4524+     pub  const  fn  split_off_last_mut < ' a > ( self :  & mut  & ' a  mut  Self )  -> Option < & ' a  mut  T >  { 
4525+         // FIXME(const-hack): Use `mem::take` and `?` when available in const. 
4526+         // Original: `mem::take(self).split_last_mut()?` 
4527+         let  Some ( ( last,  rem) )  = mem:: replace ( self ,  & mut  [ ] ) . split_last_mut ( )  else  {  return  None  } ; 
45184528        * self  = rem; 
45194529        Some ( last) 
45204530    } 
0 commit comments