@@ -291,6 +291,7 @@ where
291
291
T : Clone ,
292
292
U : ArraySize ,
293
293
{
294
+ #[ inline]
294
295
fn clone ( & self ) -> Self {
295
296
Self :: from_fn ( |n| self . 0 . as_ref ( ) [ n] . clone ( ) )
296
297
}
@@ -319,6 +320,7 @@ where
319
320
T : Default ,
320
321
U : ArraySize ,
321
322
{
323
+ #[ inline]
322
324
fn default ( ) -> Self {
323
325
Self :: from_fn ( |_| Default :: default ( ) )
324
326
}
@@ -464,6 +466,7 @@ where
464
466
/// Creates a consuming iterator, that is, one that moves each value out of
465
467
/// the array (from start to end). The array cannot be used after calling
466
468
/// this unless `T` implements `Copy`, so the whole array is copied.
469
+ #[ inline]
467
470
fn into_iter ( self ) -> Self :: IntoIter {
468
471
self . 0 . into_iter ( )
469
472
}
@@ -476,6 +479,7 @@ where
476
479
type Item = & ' a T ;
477
480
type IntoIter = Iter < ' a , T > ;
478
481
482
+ #[ inline]
479
483
fn into_iter ( self ) -> Iter < ' a , T > {
480
484
self . iter ( )
481
485
}
@@ -499,6 +503,7 @@ where
499
503
T : PartialEq ,
500
504
U : ArraySize ,
501
505
{
506
+ #[ inline]
502
507
fn eq ( & self , other : & Self ) -> bool {
503
508
self . 0 . as_ref ( ) . eq ( other. 0 . as_ref ( ) )
504
509
}
@@ -509,6 +514,7 @@ where
509
514
T : PartialEq ,
510
515
U : ArraySize < ArrayType < T > = [ T ; N ] > ,
511
516
{
517
+ #[ inline]
512
518
fn eq ( & self , other : & [ T ; N ] ) -> bool {
513
519
self . 0 . eq ( other)
514
520
}
@@ -519,6 +525,7 @@ where
519
525
T : PartialEq ,
520
526
U : ArraySize < ArrayType < T > = [ T ; N ] > ,
521
527
{
528
+ #[ inline]
522
529
fn eq ( & self , other : & Array < T , U > ) -> bool {
523
530
self . eq ( & other. 0 )
524
531
}
@@ -529,6 +536,7 @@ where
529
536
T : PartialOrd ,
530
537
U : ArraySize ,
531
538
{
539
+ #[ inline]
532
540
fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
533
541
self . 0 . as_ref ( ) . partial_cmp ( other. 0 . as_ref ( ) )
534
542
}
@@ -539,6 +547,7 @@ where
539
547
T : Ord ,
540
548
U : ArraySize ,
541
549
{
550
+ #[ inline]
542
551
fn cmp ( & self , other : & Self ) -> Ordering {
543
552
self . 0 . as_ref ( ) . cmp ( other. 0 . as_ref ( ) )
544
553
}
@@ -595,6 +604,7 @@ where
595
604
T : Zeroize ,
596
605
U : ArraySize ,
597
606
{
607
+ #[ inline]
598
608
fn zeroize ( & mut self ) {
599
609
self . 0 . as_mut ( ) . iter_mut ( ) . zeroize ( )
600
610
}
@@ -660,6 +670,18 @@ pub trait ArrayOps<T, const N: usize>:
660
670
fn map_to_core_array < F , U > ( self , f : F ) -> [ U ; N ]
661
671
where
662
672
F : FnMut ( T ) -> U ;
673
+
674
+ /// Transform slice to slice of core array type
675
+ fn cast_slice_to_core ( slice : & [ Self ] ) -> & [ [ T ; N ] ] ;
676
+
677
+ /// Transform mutable slice to mutable slice of core array type
678
+ fn cast_slice_to_core_mut ( slice : & mut [ Self ] ) -> & mut [ [ T ; N ] ] ;
679
+
680
+ /// Transform slice to slice of core array type
681
+ fn cast_slice_from_core ( slice : & [ [ T ; N ] ] ) -> & [ Self ] ;
682
+
683
+ /// Transform mutable slice to mutable slice of core array type
684
+ fn cast_slice_from_core_mut ( slice : & mut [ [ T ; N ] ] ) -> & mut [ Self ] ;
663
685
}
664
686
665
687
impl < T , const N : usize > ArrayOps < T , N > for [ T ; N ] {
@@ -697,6 +719,26 @@ impl<T, const N: usize> ArrayOps<T, N> for [T; N] {
697
719
{
698
720
self . map ( f)
699
721
}
722
+
723
+ #[ inline]
724
+ fn cast_slice_to_core ( slice : & [ Self ] ) -> & [ [ T ; N ] ] {
725
+ slice
726
+ }
727
+
728
+ #[ inline]
729
+ fn cast_slice_to_core_mut ( slice : & mut [ Self ] ) -> & mut [ [ T ; N ] ] {
730
+ slice
731
+ }
732
+
733
+ #[ inline]
734
+ fn cast_slice_from_core ( slice : & [ [ T ; N ] ] ) -> & [ Self ] {
735
+ slice
736
+ }
737
+
738
+ #[ inline]
739
+ fn cast_slice_from_core_mut ( slice : & mut [ [ T ; N ] ] ) -> & mut [ Self ] {
740
+ slice
741
+ }
700
742
}
701
743
702
744
/// Slice operations which don't have access to a const generic array size.
@@ -713,13 +755,15 @@ pub trait SliceOps<T>:
713
755
/// Splits the shared slice into a slice of `N`-element arrays.
714
756
///
715
757
/// See [`slice_as_chunks`] for more information.
758
+ #[ inline]
716
759
fn as_array_chunks < N : ArraySize > ( & self ) -> ( & [ Array < T , N > ] , & [ T ] ) {
717
760
slice_as_chunks ( self . as_ref ( ) )
718
761
}
719
762
720
763
/// Splits the exclusive slice into a slice of `N`-element arrays.
721
764
///
722
765
/// See [`slice_as_chunks_mut`] for more information.
766
+ #[ inline]
723
767
fn as_array_chunks_mut < N : ArraySize > ( & mut self ) -> ( & mut [ Array < T , N > ] , & mut [ T ] ) {
724
768
slice_as_chunks_mut ( self . as_mut ( ) )
725
769
}
@@ -774,6 +818,7 @@ impl<T, U> FromFn<T> for Array<T, U>
774
818
where
775
819
U : ArraySize ,
776
820
{
821
+ #[ inline]
777
822
fn from_fn < F > ( cb : F ) -> Self
778
823
where
779
824
F : FnMut ( usize ) -> T ,
@@ -783,6 +828,7 @@ where
783
828
}
784
829
785
830
impl < T , const N : usize > FromFn < T > for [ T ; N ] {
831
+ #[ inline]
786
832
fn from_fn < F > ( cb : F ) -> Self
787
833
where
788
834
F : FnMut ( usize ) -> T ,
@@ -797,6 +843,7 @@ impl<T, const N: usize> FromFn<T> for [T; N] {
797
843
/// # Panics
798
844
/// Panics if `N` is 0.
799
845
#[ allow( clippy:: arithmetic_side_effects) ]
846
+ #[ inline]
800
847
pub fn slice_as_chunks < T , N : ArraySize > ( buf : & [ T ] ) -> ( & [ Array < T , N > ] , & [ T ] ) {
801
848
assert_ne ! ( N :: USIZE , 0 , "chunk size must be non-zero" ) ;
802
849
// Arithmetic safety: we have checked that `N::USIZE` is not zero, thus
@@ -819,6 +866,7 @@ pub fn slice_as_chunks<T, N: ArraySize>(buf: &[T]) -> (&[Array<T, N>], &[T]) {
819
866
/// # Panics
820
867
/// Panics if `N` is 0.
821
868
#[ allow( clippy:: arithmetic_side_effects) ]
869
+ #[ inline]
822
870
pub fn slice_as_chunks_mut < T , N : ArraySize > ( buf : & mut [ T ] ) -> ( & mut [ Array < T , N > ] , & mut [ T ] ) {
823
871
assert_ne ! ( N :: USIZE , 0 , "chunk size must be non-zero" ) ;
824
872
// Arithmetic safety: we have checked that `N::USIZE` is not zero, thus
0 commit comments