@@ -568,9 +568,10 @@ impl<T> [T] {
568
568
#[ rustc_no_implicit_autorefs]
569
569
#[ inline]
570
570
#[ must_use]
571
- pub fn get < I > ( & self , index : I ) -> Option < & I :: Output >
571
+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
572
+ pub const fn get < I > ( & self , index : I ) -> Option < & I :: Output >
572
573
where
573
- I : SliceIndex < Self > ,
574
+ I : ~ const SliceIndex < Self > ,
574
575
{
575
576
index. get ( self )
576
577
}
@@ -594,9 +595,10 @@ impl<T> [T] {
594
595
#[ rustc_no_implicit_autorefs]
595
596
#[ inline]
596
597
#[ must_use]
597
- pub fn get_mut < I > ( & mut self , index : I ) -> Option < & mut I :: Output >
598
+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
599
+ pub const fn get_mut < I > ( & mut self , index : I ) -> Option < & mut I :: Output >
598
600
where
599
- I : SliceIndex < Self > ,
601
+ I : ~ const SliceIndex < Self > ,
600
602
{
601
603
index. get_mut ( self )
602
604
}
@@ -633,9 +635,10 @@ impl<T> [T] {
633
635
#[ inline]
634
636
#[ must_use]
635
637
#[ track_caller]
636
- pub unsafe fn get_unchecked < I > ( & self , index : I ) -> & I :: Output
638
+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
639
+ pub const unsafe fn get_unchecked < I > ( & self , index : I ) -> & I :: Output
637
640
where
638
- I : SliceIndex < Self > ,
641
+ I : ~ const SliceIndex < Self > ,
639
642
{
640
643
// SAFETY: the caller must uphold most of the safety requirements for `get_unchecked`;
641
644
// the slice is dereferenceable because `self` is a safe reference.
@@ -677,9 +680,10 @@ impl<T> [T] {
677
680
#[ inline]
678
681
#[ must_use]
679
682
#[ track_caller]
680
- pub unsafe fn get_unchecked_mut < I > ( & mut self , index : I ) -> & mut I :: Output
683
+ #[ rustc_const_unstable( feature = "const_index" , issue = "143775" ) ]
684
+ pub const unsafe fn get_unchecked_mut < I > ( & mut self , index : I ) -> & mut I :: Output
681
685
where
682
- I : SliceIndex < Self > ,
686
+ I : ~ const SliceIndex < Self > ,
683
687
{
684
688
// SAFETY: the caller must uphold the safety requirements for `get_unchecked_mut`;
685
689
// the slice is dereferenceable because `self` is a safe reference.
0 commit comments