@@ -4446,8 +4446,10 @@ impl<T> [T] {
44464446/// ``` 
44474447#[ inline]  
44484448    #[ stable( feature = "slice_take" ,  since = "CURRENT_RUSTC_VERSION" ) ]  
4449-     pub  fn  split_off_first < ' a > ( self :  & mut  & ' a  Self )  -> Option < & ' a  T >  { 
4450-         let  ( first,  rem)  = self . split_first ( ) ?; 
4449+     #[ rustc_const_unstable( feature = "const_split_off_first_last" ,  issue = "138539" ) ]  
4450+     pub  const  fn  split_off_first < ' a > ( self :  & mut  & ' a  Self )  -> Option < & ' a  T >  { 
4451+         // FIXME(const-hack): Use `?` when available in const instead of `let-else`. 
4452+         let  Some ( ( first,  rem) )  = self . split_first ( )  else  {  return  None  } ; 
44514453        * self  = rem; 
44524454        Some ( first) 
44534455    } 
@@ -4469,8 +4471,11 @@ impl<T> [T] {
44694471/// ``` 
44704472#[ inline]  
44714473    #[ stable( feature = "slice_take" ,  since = "CURRENT_RUSTC_VERSION" ) ]  
4472-     pub  fn  split_off_first_mut < ' a > ( self :  & mut  & ' a  mut  Self )  -> Option < & ' a  mut  T >  { 
4473-         let  ( first,  rem)  = mem:: take ( self ) . split_first_mut ( ) ?; 
4474+     #[ rustc_const_unstable( feature = "const_split_off_first_last" ,  issue = "138539" ) ]  
4475+     pub  const  fn  split_off_first_mut < ' a > ( self :  & mut  & ' a  mut  Self )  -> Option < & ' a  mut  T >  { 
4476+         // FIXME(const-hack): Use `mem::take` and `?` when available in const. 
4477+         // Original: `mem::take(self).split_first_mut()?` 
4478+         let  Some ( ( first,  rem) )  = mem:: replace ( self ,  & mut  [ ] ) . split_first_mut ( )  else  {  return  None  } ; 
44744479        * self  = rem; 
44754480        Some ( first) 
44764481    } 
@@ -4491,8 +4496,10 @@ impl<T> [T] {
44914496/// ``` 
44924497#[ inline]  
44934498    #[ stable( feature = "slice_take" ,  since = "CURRENT_RUSTC_VERSION" ) ]  
4494-     pub  fn  split_off_last < ' a > ( self :  & mut  & ' a  Self )  -> Option < & ' a  T >  { 
4495-         let  ( last,  rem)  = self . split_last ( ) ?; 
4499+     #[ rustc_const_unstable( feature = "const_split_off_first_last" ,  issue = "138539" ) ]  
4500+     pub  const  fn  split_off_last < ' a > ( self :  & mut  & ' a  Self )  -> Option < & ' a  T >  { 
4501+         // FIXME(const-hack): Use `?` when available in const instead of `let-else`. 
4502+         let  Some ( ( last,  rem) )  = self . split_last ( )  else  {  return  None  } ; 
44964503        * self  = rem; 
44974504        Some ( last) 
44984505    } 
@@ -4514,8 +4521,11 @@ impl<T> [T] {
45144521/// ``` 
45154522#[ inline]  
45164523    #[ stable( feature = "slice_take" ,  since = "CURRENT_RUSTC_VERSION" ) ]  
4517-     pub  fn  split_off_last_mut < ' a > ( self :  & mut  & ' a  mut  Self )  -> Option < & ' a  mut  T >  { 
4518-         let  ( last,  rem)  = mem:: take ( self ) . split_last_mut ( ) ?; 
4524+     #[ rustc_const_unstable( feature = "const_split_off_first_last" ,  issue = "138539" ) ]  
4525+     pub  const  fn  split_off_last_mut < ' a > ( self :  & mut  & ' a  mut  Self )  -> Option < & ' a  mut  T >  { 
4526+         // FIXME(const-hack): Use `mem::take` and `?` when available in const. 
4527+         // Original: `mem::take(self).split_last_mut()?` 
4528+         let  Some ( ( last,  rem) )  = mem:: replace ( self ,  & mut  [ ] ) . split_last_mut ( )  else  {  return  None  } ; 
45194529        * self  = rem; 
45204530        Some ( last) 
45214531    } 
0 commit comments