@@ -805,8 +805,9 @@ impl<T> [T] {
805
805
/// ```
806
806
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
807
807
#[ inline]
808
+ #[ track_caller]
808
809
pub fn windows ( & self , size : usize ) -> Windows < ' _ , T > {
809
- let size = NonZeroUsize :: new ( size) . expect ( "size is zero" ) ;
810
+ let size = NonZeroUsize :: new ( size) . expect ( "window size must be non- zero" ) ;
810
811
Windows :: new ( self , size)
811
812
}
812
813
@@ -839,8 +840,9 @@ impl<T> [T] {
839
840
/// [`rchunks`]: slice::rchunks
840
841
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
841
842
#[ inline]
843
+ #[ track_caller]
842
844
pub fn chunks ( & self , chunk_size : usize ) -> Chunks < ' _ , T > {
843
- assert_ne ! ( chunk_size, 0 , "chunks cannot have a size of zero" ) ;
845
+ assert ! ( chunk_size != 0 , "chunk size must be non- zero" ) ;
844
846
Chunks :: new ( self , chunk_size)
845
847
}
846
848
@@ -877,8 +879,9 @@ impl<T> [T] {
877
879
/// [`rchunks_mut`]: slice::rchunks_mut
878
880
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
879
881
#[ inline]
882
+ #[ track_caller]
880
883
pub fn chunks_mut ( & mut self , chunk_size : usize ) -> ChunksMut < ' _ , T > {
881
- assert_ne ! ( chunk_size, 0 , "chunks cannot have a size of zero" ) ;
884
+ assert ! ( chunk_size != 0 , "chunk size must be non- zero" ) ;
882
885
ChunksMut :: new ( self , chunk_size)
883
886
}
884
887
@@ -914,8 +917,9 @@ impl<T> [T] {
914
917
/// [`rchunks_exact`]: slice::rchunks_exact
915
918
#[ stable( feature = "chunks_exact" , since = "1.31.0" ) ]
916
919
#[ inline]
920
+ #[ track_caller]
917
921
pub fn chunks_exact ( & self , chunk_size : usize ) -> ChunksExact < ' _ , T > {
918
- assert_ne ! ( chunk_size, 0 , "chunks cannot have a size of zero" ) ;
922
+ assert ! ( chunk_size != 0 , "chunk size must be non- zero" ) ;
919
923
ChunksExact :: new ( self , chunk_size)
920
924
}
921
925
@@ -956,8 +960,9 @@ impl<T> [T] {
956
960
/// [`rchunks_exact_mut`]: slice::rchunks_exact_mut
957
961
#[ stable( feature = "chunks_exact" , since = "1.31.0" ) ]
958
962
#[ inline]
963
+ #[ track_caller]
959
964
pub fn chunks_exact_mut ( & mut self , chunk_size : usize ) -> ChunksExactMut < ' _ , T > {
960
- assert_ne ! ( chunk_size, 0 , "chunks cannot have a size of zero" ) ;
965
+ assert ! ( chunk_size != 0 , "chunk size must be non- zero" ) ;
961
966
ChunksExactMut :: new ( self , chunk_size)
962
967
}
963
968
@@ -1037,9 +1042,10 @@ impl<T> [T] {
1037
1042
/// ```
1038
1043
#[ unstable( feature = "slice_as_chunks" , issue = "74985" ) ]
1039
1044
#[ inline]
1045
+ #[ track_caller]
1040
1046
#[ must_use]
1041
1047
pub fn as_chunks < const N : usize > ( & self ) -> ( & [ [ T ; N ] ] , & [ T ] ) {
1042
- assert_ne ! ( N , 0 , "chunks cannot have a size of zero" ) ;
1048
+ assert ! ( N != 0 , "chunk size must be non- zero" ) ;
1043
1049
let len = self . len ( ) / N ;
1044
1050
let ( multiple_of_n, remainder) = self . split_at ( len * N ) ;
1045
1051
// SAFETY: We already panicked for zero, and ensured by construction
@@ -1068,9 +1074,10 @@ impl<T> [T] {
1068
1074
/// ```
1069
1075
#[ unstable( feature = "slice_as_chunks" , issue = "74985" ) ]
1070
1076
#[ inline]
1077
+ #[ track_caller]
1071
1078
#[ must_use]
1072
1079
pub fn as_rchunks < const N : usize > ( & self ) -> ( & [ T ] , & [ [ T ; N ] ] ) {
1073
- assert_ne ! ( N , 0 , "chunks cannot have a size of zero" ) ;
1080
+ assert ! ( N != 0 , "chunk size must be non- zero" ) ;
1074
1081
let len = self . len ( ) / N ;
1075
1082
let ( remainder, multiple_of_n) = self . split_at ( self . len ( ) - len * N ) ;
1076
1083
// SAFETY: We already panicked for zero, and ensured by construction
@@ -1108,8 +1115,9 @@ impl<T> [T] {
1108
1115
/// [`chunks_exact`]: slice::chunks_exact
1109
1116
#[ unstable( feature = "array_chunks" , issue = "74985" ) ]
1110
1117
#[ inline]
1118
+ #[ track_caller]
1111
1119
pub fn array_chunks < const N : usize > ( & self ) -> ArrayChunks < ' _ , T , N > {
1112
- assert_ne ! ( N , 0 , "chunks cannot have a size of zero" ) ;
1120
+ assert ! ( N != 0 , "chunk size must be non- zero" ) ;
1113
1121
ArrayChunks :: new ( self )
1114
1122
}
1115
1123
@@ -1186,9 +1194,10 @@ impl<T> [T] {
1186
1194
/// ```
1187
1195
#[ unstable( feature = "slice_as_chunks" , issue = "74985" ) ]
1188
1196
#[ inline]
1197
+ #[ track_caller]
1189
1198
#[ must_use]
1190
1199
pub fn as_chunks_mut < const N : usize > ( & mut self ) -> ( & mut [ [ T ; N ] ] , & mut [ T ] ) {
1191
- assert_ne ! ( N , 0 , "chunks cannot have a size of zero" ) ;
1200
+ assert ! ( N != 0 , "chunk size must be non- zero" ) ;
1192
1201
let len = self . len ( ) / N ;
1193
1202
let ( multiple_of_n, remainder) = self . split_at_mut ( len * N ) ;
1194
1203
// SAFETY: We already panicked for zero, and ensured by construction
@@ -1223,9 +1232,10 @@ impl<T> [T] {
1223
1232
/// ```
1224
1233
#[ unstable( feature = "slice_as_chunks" , issue = "74985" ) ]
1225
1234
#[ inline]
1235
+ #[ track_caller]
1226
1236
#[ must_use]
1227
1237
pub fn as_rchunks_mut < const N : usize > ( & mut self ) -> ( & mut [ T ] , & mut [ [ T ; N ] ] ) {
1228
- assert_ne ! ( N , 0 , "chunks cannot have a size of zero" ) ;
1238
+ assert ! ( N != 0 , "chunk size must be non- zero" ) ;
1229
1239
let len = self . len ( ) / N ;
1230
1240
let ( remainder, multiple_of_n) = self . split_at_mut ( self . len ( ) - len * N ) ;
1231
1241
// SAFETY: We already panicked for zero, and ensured by construction
@@ -1265,8 +1275,9 @@ impl<T> [T] {
1265
1275
/// [`chunks_exact_mut`]: slice::chunks_exact_mut
1266
1276
#[ unstable( feature = "array_chunks" , issue = "74985" ) ]
1267
1277
#[ inline]
1278
+ #[ track_caller]
1268
1279
pub fn array_chunks_mut < const N : usize > ( & mut self ) -> ArrayChunksMut < ' _ , T , N > {
1269
- assert_ne ! ( N , 0 , "chunks cannot have a size of zero" ) ;
1280
+ assert ! ( N != 0 , "chunk size must be non- zero" ) ;
1270
1281
ArrayChunksMut :: new ( self )
1271
1282
}
1272
1283
@@ -1297,8 +1308,9 @@ impl<T> [T] {
1297
1308
/// [`windows`]: slice::windows
1298
1309
#[ unstable( feature = "array_windows" , issue = "75027" ) ]
1299
1310
#[ inline]
1311
+ #[ track_caller]
1300
1312
pub fn array_windows < const N : usize > ( & self ) -> ArrayWindows < ' _ , T , N > {
1301
- assert_ne ! ( N , 0 , "windows cannot have a size of zero" ) ;
1313
+ assert ! ( N != 0 , "window size must be non- zero" ) ;
1302
1314
ArrayWindows :: new ( self )
1303
1315
}
1304
1316
@@ -1331,8 +1343,9 @@ impl<T> [T] {
1331
1343
/// [`chunks`]: slice::chunks
1332
1344
#[ stable( feature = "rchunks" , since = "1.31.0" ) ]
1333
1345
#[ inline]
1346
+ #[ track_caller]
1334
1347
pub fn rchunks ( & self , chunk_size : usize ) -> RChunks < ' _ , T > {
1335
- assert ! ( chunk_size != 0 ) ;
1348
+ assert ! ( chunk_size != 0 , "chunk size must be non-zero" ) ;
1336
1349
RChunks :: new ( self , chunk_size)
1337
1350
}
1338
1351
@@ -1369,8 +1382,9 @@ impl<T> [T] {
1369
1382
/// [`chunks_mut`]: slice::chunks_mut
1370
1383
#[ stable( feature = "rchunks" , since = "1.31.0" ) ]
1371
1384
#[ inline]
1385
+ #[ track_caller]
1372
1386
pub fn rchunks_mut ( & mut self , chunk_size : usize ) -> RChunksMut < ' _ , T > {
1373
- assert ! ( chunk_size != 0 ) ;
1387
+ assert ! ( chunk_size != 0 , "chunk size must be non-zero" ) ;
1374
1388
RChunksMut :: new ( self , chunk_size)
1375
1389
}
1376
1390
@@ -1408,8 +1422,9 @@ impl<T> [T] {
1408
1422
/// [`chunks_exact`]: slice::chunks_exact
1409
1423
#[ stable( feature = "rchunks" , since = "1.31.0" ) ]
1410
1424
#[ inline]
1425
+ #[ track_caller]
1411
1426
pub fn rchunks_exact ( & self , chunk_size : usize ) -> RChunksExact < ' _ , T > {
1412
- assert ! ( chunk_size != 0 ) ;
1427
+ assert ! ( chunk_size != 0 , "chunk size must be non-zero" ) ;
1413
1428
RChunksExact :: new ( self , chunk_size)
1414
1429
}
1415
1430
@@ -1451,8 +1466,9 @@ impl<T> [T] {
1451
1466
/// [`chunks_exact_mut`]: slice::chunks_exact_mut
1452
1467
#[ stable( feature = "rchunks" , since = "1.31.0" ) ]
1453
1468
#[ inline]
1469
+ #[ track_caller]
1454
1470
pub fn rchunks_exact_mut ( & mut self , chunk_size : usize ) -> RChunksExactMut < ' _ , T > {
1455
- assert ! ( chunk_size != 0 ) ;
1471
+ assert ! ( chunk_size != 0 , "chunk size must be non-zero" ) ;
1456
1472
RChunksExactMut :: new ( self , chunk_size)
1457
1473
}
1458
1474
0 commit comments