@@ -145,8 +145,9 @@ impl<T> [T] {
145145 /// assert_eq!(None, w.first());
146146 /// ```
147147 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
148+ #[ rustc_const_unstable( feature = "const_slice_first_last" , issue = "83570" ) ]
148149 #[ inline]
149- pub fn first ( & self ) -> Option < & T > {
150+ pub const fn first ( & self ) -> Option < & T > {
150151 if let [ first, ..] = self { Some ( first) } else { None }
151152 }
152153
@@ -163,8 +164,9 @@ impl<T> [T] {
163164 /// assert_eq!(x, &[5, 1, 2]);
164165 /// ```
165166 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
167+ #[ rustc_const_unstable( feature = "const_slice_first_last" , issue = "83570" ) ]
166168 #[ inline]
167- pub fn first_mut ( & mut self ) -> Option < & mut T > {
169+ pub const fn first_mut ( & mut self ) -> Option < & mut T > {
168170 if let [ first, ..] = self { Some ( first) } else { None }
169171 }
170172
@@ -181,8 +183,9 @@ impl<T> [T] {
181183 /// }
182184 /// ```
183185 #[ stable( feature = "slice_splits" , since = "1.5.0" ) ]
186+ #[ rustc_const_unstable( feature = "const_slice_first_last" , issue = "83570" ) ]
184187 #[ inline]
185- pub fn split_first ( & self ) -> Option < ( & T , & [ T ] ) > {
188+ pub const fn split_first ( & self ) -> Option < ( & T , & [ T ] ) > {
186189 if let [ first, tail @ ..] = self { Some ( ( first, tail) ) } else { None }
187190 }
188191
@@ -201,8 +204,9 @@ impl<T> [T] {
201204 /// assert_eq!(x, &[3, 4, 5]);
202205 /// ```
203206 #[ stable( feature = "slice_splits" , since = "1.5.0" ) ]
207+ #[ rustc_const_unstable( feature = "const_slice_first_last" , issue = "83570" ) ]
204208 #[ inline]
205- pub fn split_first_mut ( & mut self ) -> Option < ( & mut T , & mut [ T ] ) > {
209+ pub const fn split_first_mut ( & mut self ) -> Option < ( & mut T , & mut [ T ] ) > {
206210 if let [ first, tail @ ..] = self { Some ( ( first, tail) ) } else { None }
207211 }
208212
@@ -219,8 +223,9 @@ impl<T> [T] {
219223 /// }
220224 /// ```
221225 #[ stable( feature = "slice_splits" , since = "1.5.0" ) ]
226+ #[ rustc_const_unstable( feature = "const_slice_first_last" , issue = "83570" ) ]
222227 #[ inline]
223- pub fn split_last ( & self ) -> Option < ( & T , & [ T ] ) > {
228+ pub const fn split_last ( & self ) -> Option < ( & T , & [ T ] ) > {
224229 if let [ init @ .., last] = self { Some ( ( last, init) ) } else { None }
225230 }
226231
@@ -239,8 +244,9 @@ impl<T> [T] {
239244 /// assert_eq!(x, &[4, 5, 3]);
240245 /// ```
241246 #[ stable( feature = "slice_splits" , since = "1.5.0" ) ]
247+ #[ rustc_const_unstable( feature = "const_slice_first_last" , issue = "83570" ) ]
242248 #[ inline]
243- pub fn split_last_mut ( & mut self ) -> Option < ( & mut T , & mut [ T ] ) > {
249+ pub const fn split_last_mut ( & mut self ) -> Option < ( & mut T , & mut [ T ] ) > {
244250 if let [ init @ .., last] = self { Some ( ( last, init) ) } else { None }
245251 }
246252
@@ -256,8 +262,9 @@ impl<T> [T] {
256262 /// assert_eq!(None, w.last());
257263 /// ```
258264 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
265+ #[ rustc_const_unstable( feature = "const_slice_first_last" , issue = "83570" ) ]
259266 #[ inline]
260- pub fn last ( & self ) -> Option < & T > {
267+ pub const fn last ( & self ) -> Option < & T > {
261268 if let [ .., last] = self { Some ( last) } else { None }
262269 }
263270
@@ -274,8 +281,9 @@ impl<T> [T] {
274281 /// assert_eq!(x, &[0, 1, 10]);
275282 /// ```
276283 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
284+ #[ rustc_const_unstable( feature = "const_slice_first_last" , issue = "83570" ) ]
277285 #[ inline]
278- pub fn last_mut ( & mut self ) -> Option < & mut T > {
286+ pub const fn last_mut ( & mut self ) -> Option < & mut T > {
279287 if let [ .., last] = self { Some ( last) } else { None }
280288 }
281289
0 commit comments