@@ -1043,9 +1043,10 @@ impl<T> [T] {
1043
1043
/// assert_eq!(iterator.next(), None);
1044
1044
/// ```
1045
1045
#[stable(feature = "rust1", since = "1.0.0")]
1046
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1046
1047
#[inline]
1047
1048
#[rustc_diagnostic_item = "slice_iter"]
1048
- pub fn iter ( & self ) -> Iter < ' _ , T > {
1049
+ pub const fn iter(&self) -> Iter<'_, T> {
1049
1050
Iter::new(self)
1050
1051
}
1051
1052
@@ -1062,9 +1063,10 @@ impl<T> [T] {
1062
1063
/// }
1063
1064
/// assert_eq!(x, &[3, 4, 6]);
1064
1065
/// ```
1066
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1065
1067
#[stable(feature = "rust1", since = "1.0.0")]
1066
1068
#[inline]
1067
- pub fn iter_mut ( & mut self ) -> IterMut < ' _ , T > {
1069
+ pub const fn iter_mut(&mut self) -> IterMut<'_, T> {
1068
1070
IterMut::new(self)
1069
1071
}
1070
1072
@@ -1116,9 +1118,10 @@ impl<T> [T] {
1116
1118
/// assert_eq!(array, ['s', 't', ' ', '2', '0', '1', '5', 'u', 'R']);
1117
1119
/// ```
1118
1120
#[stable(feature = "rust1", since = "1.0.0")]
1121
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1119
1122
#[inline]
1120
1123
#[track_caller]
1121
- pub fn windows ( & self , size : usize ) -> Windows < ' _ , T > {
1124
+ pub const fn windows(&self, size: usize) -> Windows<'_, T> {
1122
1125
let size = NonZero::new(size).expect("window size must be non-zero");
1123
1126
Windows::new(self, size)
1124
1127
}
@@ -1151,9 +1154,10 @@ impl<T> [T] {
1151
1154
/// [`chunks_exact`]: slice::chunks_exact
1152
1155
/// [`rchunks`]: slice::rchunks
1153
1156
#[stable(feature = "rust1", since = "1.0.0")]
1157
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1154
1158
#[inline]
1155
1159
#[track_caller]
1156
- pub fn chunks ( & self , chunk_size : usize ) -> Chunks < ' _ , T > {
1160
+ pub const fn chunks(&self, chunk_size: usize) -> Chunks<'_, T> {
1157
1161
assert!(chunk_size != 0, "chunk size must be non-zero");
1158
1162
Chunks::new(self, chunk_size)
1159
1163
}
@@ -1190,9 +1194,10 @@ impl<T> [T] {
1190
1194
/// [`chunks_exact_mut`]: slice::chunks_exact_mut
1191
1195
/// [`rchunks_mut`]: slice::rchunks_mut
1192
1196
#[stable(feature = "rust1", since = "1.0.0")]
1197
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1193
1198
#[inline]
1194
1199
#[track_caller]
1195
- pub fn chunks_mut ( & mut self , chunk_size : usize ) -> ChunksMut < ' _ , T > {
1200
+ pub const fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<'_, T> {
1196
1201
assert!(chunk_size != 0, "chunk size must be non-zero");
1197
1202
ChunksMut::new(self, chunk_size)
1198
1203
}
@@ -1228,9 +1233,10 @@ impl<T> [T] {
1228
1233
/// [`chunks`]: slice::chunks
1229
1234
/// [`rchunks_exact`]: slice::rchunks_exact
1230
1235
#[stable(feature = "chunks_exact", since = "1.31.0")]
1236
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1231
1237
#[inline]
1232
1238
#[track_caller]
1233
- pub fn chunks_exact ( & self , chunk_size : usize ) -> ChunksExact < ' _ , T > {
1239
+ pub const fn chunks_exact(&self, chunk_size: usize) -> ChunksExact<'_, T> {
1234
1240
assert!(chunk_size != 0, "chunk size must be non-zero");
1235
1241
ChunksExact::new(self, chunk_size)
1236
1242
}
@@ -1271,9 +1277,10 @@ impl<T> [T] {
1271
1277
/// [`chunks_mut`]: slice::chunks_mut
1272
1278
/// [`rchunks_exact_mut`]: slice::rchunks_exact_mut
1273
1279
#[stable(feature = "chunks_exact", since = "1.31.0")]
1280
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1274
1281
#[inline]
1275
1282
#[track_caller]
1276
- pub fn chunks_exact_mut ( & mut self , chunk_size : usize ) -> ChunksExactMut < ' _ , T > {
1283
+ pub const fn chunks_exact_mut(&mut self, chunk_size: usize) -> ChunksExactMut<'_, T> {
1277
1284
assert!(chunk_size != 0, "chunk size must be non-zero");
1278
1285
ChunksExactMut::new(self, chunk_size)
1279
1286
}
@@ -1429,9 +1436,10 @@ impl<T> [T] {
1429
1436
///
1430
1437
/// [`chunks_exact`]: slice::chunks_exact
1431
1438
#[unstable(feature = "array_chunks", issue = "74985")]
1439
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1432
1440
#[inline]
1433
1441
#[track_caller]
1434
- pub fn array_chunks < const N : usize > ( & self ) -> ArrayChunks < ' _ , T , N > {
1442
+ pub const fn array_chunks<const N: usize>(&self) -> ArrayChunks<'_, T, N> {
1435
1443
assert!(N != 0, "chunk size must be non-zero");
1436
1444
ArrayChunks::new(self)
1437
1445
}
@@ -1592,9 +1600,10 @@ impl<T> [T] {
1592
1600
///
1593
1601
/// [`chunks_exact_mut`]: slice::chunks_exact_mut
1594
1602
#[unstable(feature = "array_chunks", issue = "74985")]
1603
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1595
1604
#[inline]
1596
1605
#[track_caller]
1597
- pub fn array_chunks_mut < const N : usize > ( & mut self ) -> ArrayChunksMut < ' _ , T , N > {
1606
+ pub const fn array_chunks_mut<const N: usize>(&mut self) -> ArrayChunksMut<'_, T, N> {
1598
1607
assert!(N != 0, "chunk size must be non-zero");
1599
1608
ArrayChunksMut::new(self)
1600
1609
}
@@ -1625,9 +1634,10 @@ impl<T> [T] {
1625
1634
///
1626
1635
/// [`windows`]: slice::windows
1627
1636
#[unstable(feature = "array_windows", issue = "75027")]
1637
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1628
1638
#[inline]
1629
1639
#[track_caller]
1630
- pub fn array_windows < const N : usize > ( & self ) -> ArrayWindows < ' _ , T , N > {
1640
+ pub const fn array_windows<const N: usize>(&self) -> ArrayWindows<'_, T, N> {
1631
1641
assert!(N != 0, "window size must be non-zero");
1632
1642
ArrayWindows::new(self)
1633
1643
}
@@ -1660,9 +1670,10 @@ impl<T> [T] {
1660
1670
/// [`rchunks_exact`]: slice::rchunks_exact
1661
1671
/// [`chunks`]: slice::chunks
1662
1672
#[stable(feature = "rchunks", since = "1.31.0")]
1673
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1663
1674
#[inline]
1664
1675
#[track_caller]
1665
- pub fn rchunks ( & self , chunk_size : usize ) -> RChunks < ' _ , T > {
1676
+ pub const fn rchunks(&self, chunk_size: usize) -> RChunks<'_, T> {
1666
1677
assert!(chunk_size != 0, "chunk size must be non-zero");
1667
1678
RChunks::new(self, chunk_size)
1668
1679
}
@@ -1699,9 +1710,10 @@ impl<T> [T] {
1699
1710
/// [`rchunks_exact_mut`]: slice::rchunks_exact_mut
1700
1711
/// [`chunks_mut`]: slice::chunks_mut
1701
1712
#[stable(feature = "rchunks", since = "1.31.0")]
1713
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1702
1714
#[inline]
1703
1715
#[track_caller]
1704
- pub fn rchunks_mut ( & mut self , chunk_size : usize ) -> RChunksMut < ' _ , T > {
1716
+ pub const fn rchunks_mut(&mut self, chunk_size: usize) -> RChunksMut<'_, T> {
1705
1717
assert!(chunk_size != 0, "chunk size must be non-zero");
1706
1718
RChunksMut::new(self, chunk_size)
1707
1719
}
@@ -1739,9 +1751,10 @@ impl<T> [T] {
1739
1751
/// [`rchunks`]: slice::rchunks
1740
1752
/// [`chunks_exact`]: slice::chunks_exact
1741
1753
#[stable(feature = "rchunks", since = "1.31.0")]
1754
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1742
1755
#[inline]
1743
1756
#[track_caller]
1744
- pub fn rchunks_exact ( & self , chunk_size : usize ) -> RChunksExact < ' _ , T > {
1757
+ pub const fn rchunks_exact(&self, chunk_size: usize) -> RChunksExact<'_, T> {
1745
1758
assert!(chunk_size != 0, "chunk size must be non-zero");
1746
1759
RChunksExact::new(self, chunk_size)
1747
1760
}
@@ -1783,9 +1796,10 @@ impl<T> [T] {
1783
1796
/// [`rchunks_mut`]: slice::rchunks_mut
1784
1797
/// [`chunks_exact_mut`]: slice::chunks_exact_mut
1785
1798
#[stable(feature = "rchunks", since = "1.31.0")]
1799
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1786
1800
#[inline]
1787
1801
#[track_caller]
1788
- pub fn rchunks_exact_mut ( & mut self , chunk_size : usize ) -> RChunksExactMut < ' _ , T > {
1802
+ pub const fn rchunks_exact_mut(&mut self, chunk_size: usize) -> RChunksExactMut<'_, T> {
1789
1803
assert!(chunk_size != 0, "chunk size must be non-zero");
1790
1804
RChunksExactMut::new(self, chunk_size)
1791
1805
}
@@ -1823,8 +1837,9 @@ impl<T> [T] {
1823
1837
/// assert_eq!(iter.next(), None);
1824
1838
/// ```
1825
1839
#[stable(feature = "slice_group_by", since = "1.77.0")]
1840
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1826
1841
#[inline]
1827
- pub fn chunk_by < F > ( & self , pred : F ) -> ChunkBy < ' _ , T , F >
1842
+ pub const fn chunk_by<F>(&self, pred: F) -> ChunkBy<'_, T, F>
1828
1843
where
1829
1844
F: FnMut(&T, &T) -> bool,
1830
1845
{
@@ -1864,8 +1879,9 @@ impl<T> [T] {
1864
1879
/// assert_eq!(iter.next(), None);
1865
1880
/// ```
1866
1881
#[stable(feature = "slice_group_by", since = "1.77.0")]
1882
+ #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
1867
1883
#[inline]
1868
- pub fn chunk_by_mut < F > ( & mut self , pred : F ) -> ChunkByMut < ' _ , T , F >
1884
+ pub const fn chunk_by_mut<F>(&mut self, pred: F) -> ChunkByMut<'_, T, F>
1869
1885
where
1870
1886
F: FnMut(&T, &T) -> bool,
1871
1887
{
0 commit comments