@@ -292,8 +292,8 @@ where
292
292
/// Panics if `U` is 0.
293
293
#[ allow( clippy:: arithmetic_side_effects) ]
294
294
#[ inline]
295
- pub fn slice_as_chunks ( buf : & [ T ] ) -> ( & [ Self ] , & [ T ] ) {
296
- assert_ne ! ( U :: USIZE , 0 , "chunk size must be non-zero" ) ;
295
+ pub const fn slice_as_chunks ( buf : & [ T ] ) -> ( & [ Self ] , & [ T ] ) {
296
+ assert ! ( U :: USIZE != 0 , "chunk size must be non-zero" ) ;
297
297
// Arithmetic safety: we have checked that `N::USIZE` is not zero, thus
298
298
// division always returns correct result. `tail_pos` can not be bigger than `buf.len()`,
299
299
// thus overflow on multiplication and underflow on substraction are impossible.
@@ -315,8 +315,8 @@ where
315
315
/// Panics if `U` is 0.
316
316
#[ allow( clippy:: arithmetic_side_effects) ]
317
317
#[ inline]
318
- pub fn slice_as_chunks_mut ( buf : & mut [ T ] ) -> ( & mut [ Self ] , & mut [ T ] ) {
319
- assert_ne ! ( U :: USIZE , 0 , "chunk size must be non-zero" ) ;
318
+ pub const fn slice_as_chunks_mut ( buf : & mut [ T ] ) -> ( & mut [ Self ] , & mut [ T ] ) {
319
+ assert ! ( U :: USIZE != 0 , "chunk size must be non-zero" ) ;
320
320
// Arithmetic safety: we have checked that `N::USIZE` is not zero, thus
321
321
// division always returns correct result. `tail_pos` can not be bigger than `buf.len()`,
322
322
// thus overflow on multiplication and underflow on substraction are impossible.
@@ -375,28 +375,28 @@ where
375
375
{
376
376
/// Transform slice to slice of core array type.
377
377
#[ inline]
378
- pub fn cast_slice_to_core ( slice : & [ Self ] ) -> & [ [ T ; N ] ] {
378
+ pub const fn cast_slice_to_core ( slice : & [ Self ] ) -> & [ [ T ; N ] ] {
379
379
// SAFETY: `Self` is a `repr(transparent)` newtype for `[T; N]`
380
380
unsafe { slice:: from_raw_parts ( slice. as_ptr ( ) . cast ( ) , slice. len ( ) ) }
381
381
}
382
382
383
383
/// Transform mutable slice to mutable slice of core array type.
384
384
#[ inline]
385
- pub fn cast_slice_to_core_mut ( slice : & mut [ Self ] ) -> & mut [ [ T ; N ] ] {
385
+ pub const fn cast_slice_to_core_mut ( slice : & mut [ Self ] ) -> & mut [ [ T ; N ] ] {
386
386
// SAFETY: `Self` is a `repr(transparent)` newtype for `[T; N]`
387
387
unsafe { slice:: from_raw_parts_mut ( slice. as_mut_ptr ( ) . cast ( ) , slice. len ( ) ) }
388
388
}
389
389
390
390
/// Transform slice to slice of core array type.
391
391
#[ inline]
392
- pub fn cast_slice_from_core ( slice : & [ [ T ; N ] ] ) -> & [ Self ] {
392
+ pub const fn cast_slice_from_core ( slice : & [ [ T ; N ] ] ) -> & [ Self ] {
393
393
// SAFETY: `Self` is a `repr(transparent)` newtype for `[T; N]`
394
394
unsafe { slice:: from_raw_parts ( slice. as_ptr ( ) . cast ( ) , slice. len ( ) ) }
395
395
}
396
396
397
397
/// Transform mutable slice to mutable slice of core array type.
398
398
#[ inline]
399
- pub fn cast_slice_from_core_mut ( slice : & mut [ [ T ; N ] ] ) -> & mut [ Self ] {
399
+ pub const fn cast_slice_from_core_mut ( slice : & mut [ [ T ; N ] ] ) -> & mut [ Self ] {
400
400
// SAFETY: `Self` is a `repr(transparent)` newtype for `[T; N]`
401
401
unsafe { slice:: from_raw_parts_mut ( slice. as_mut_ptr ( ) . cast ( ) , slice. len ( ) ) }
402
402
}
0 commit comments