@@ -113,6 +113,7 @@ where
113
113
/// Converts a reference to `T` into a reference to an array of length 1 (without copying).
114
114
#[ stable( feature = "array_from_ref" , since = "1.53.0" ) ]
115
115
#[ rustc_const_stable( feature = "const_array_from_ref_shared" , since = "1.63.0" ) ]
116
+ #[ inline]
116
117
pub const fn from_ref < T > ( s : & T ) -> & [ T ; 1 ] {
117
118
// SAFETY: Converting `&T` to `&[T; 1]` is sound.
118
119
unsafe { & * ( s as * const T ) . cast :: < [ T ; 1 ] > ( ) }
@@ -121,6 +122,7 @@ pub const fn from_ref<T>(s: &T) -> &[T; 1] {
121
122
/// Converts a mutable reference to `T` into a mutable reference to an array of length 1 (without copying).
122
123
#[ stable( feature = "array_from_ref" , since = "1.53.0" ) ]
123
124
#[ rustc_const_unstable( feature = "const_array_from_ref" , issue = "90206" ) ]
125
+ #[ inline]
124
126
pub const fn from_mut < T > ( s : & mut T ) -> & mut [ T ; 1 ] {
125
127
// SAFETY: Converting `&mut T` to `&mut [T; 1]` is sound.
126
128
unsafe { & mut * ( s as * mut T ) . cast :: < [ T ; 1 ] > ( ) }
@@ -143,13 +145,15 @@ impl fmt::Display for TryFromSliceError {
143
145
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
144
146
impl Error for TryFromSliceError {
145
147
#[ allow( deprecated) ]
148
+ #[ inline]
146
149
fn description ( & self ) -> & str {
147
150
"could not convert slice to array"
148
151
}
149
152
}
150
153
151
154
#[ stable( feature = "try_from_slice_error" , since = "1.36.0" ) ]
152
155
impl From < Infallible > for TryFromSliceError {
156
+ #[ inline]
153
157
fn from ( x : Infallible ) -> TryFromSliceError {
154
158
match x { }
155
159
}
@@ -173,13 +177,15 @@ impl<T, const N: usize> AsMut<[T]> for [T; N] {
173
177
174
178
#[ stable( feature = "array_borrow" , since = "1.4.0" ) ]
175
179
impl < T , const N : usize > Borrow < [ T ] > for [ T ; N ] {
180
+ #[ inline]
176
181
fn borrow ( & self ) -> & [ T ] {
177
182
self
178
183
}
179
184
}
180
185
181
186
#[ stable( feature = "array_borrow" , since = "1.4.0" ) ]
182
187
impl < T , const N : usize > BorrowMut < [ T ] > for [ T ; N ] {
188
+ #[ inline]
183
189
fn borrow_mut ( & mut self ) -> & mut [ T ] {
184
190
self
185
191
}
@@ -321,6 +327,7 @@ impl<'a, T, const N: usize> IntoIterator for &'a [T; N] {
321
327
type Item = & ' a T ;
322
328
type IntoIter = Iter < ' a , T > ;
323
329
330
+ #[ inline]
324
331
fn into_iter ( self ) -> Iter < ' a , T > {
325
332
self . iter ( )
326
333
}
@@ -331,6 +338,7 @@ impl<'a, T, const N: usize> IntoIterator for &'a mut [T; N] {
331
338
type Item = & ' a mut T ;
332
339
type IntoIter = IterMut < ' a , T > ;
333
340
341
+ #[ inline]
334
342
fn into_iter ( self ) -> IterMut < ' a , T > {
335
343
self . iter_mut ( )
336
344
}
@@ -435,6 +443,7 @@ macro_rules! array_impl_default {
435
443
{ $n: expr, $t: ident $( $ts: ident) * } => {
436
444
#[ stable( since = "1.4.0" , feature = "array_default" ) ]
437
445
impl <T > Default for [ T ; $n] where T : Default {
446
+ #[ inline]
438
447
fn default ( ) -> [ T ; $n] {
439
448
[ $t:: default ( ) , $( $ts:: default ( ) ) ,* ]
440
449
}
@@ -444,6 +453,7 @@ macro_rules! array_impl_default {
444
453
{ $n: expr, } => {
445
454
#[ stable( since = "1.4.0" , feature = "array_default" ) ]
446
455
impl <T > Default for [ T ; $n] {
456
+ #[ inline]
447
457
fn default ( ) -> [ T ; $n] { [ ] }
448
458
}
449
459
} ;
@@ -541,13 +551,15 @@ impl<T, const N: usize> [T; N] {
541
551
/// Returns a slice containing the entire array. Equivalent to `&s[..]`.
542
552
#[ stable( feature = "array_as_slice" , since = "1.57.0" ) ]
543
553
#[ rustc_const_stable( feature = "array_as_slice" , since = "1.57.0" ) ]
554
+ #[ inline]
544
555
pub const fn as_slice ( & self ) -> & [ T ] {
545
556
self
546
557
}
547
558
548
559
/// Returns a mutable slice containing the entire array. Equivalent to
549
560
/// `&mut s[..]`.
550
561
#[ stable( feature = "array_as_slice" , since = "1.57.0" ) ]
562
+ #[ inline]
551
563
pub fn as_mut_slice ( & mut self ) -> & mut [ T ] {
552
564
self
553
565
}
@@ -783,7 +795,7 @@ where
783
795
R : Try < Output = T > ,
784
796
R :: Residual : Residual < [ T ; N ] > ,
785
797
{
786
- assert ! ( iter . size_hint ( ) . 0 >= N ) ;
798
+ # [ inline ]
787
799
fn next < T > ( mut iter : impl UncheckedIterator < Item = T > ) -> impl FnMut ( usize ) -> T {
788
800
move |_| {
789
801
// SAFETY: We know that `from_fn` will call this at most N times,
@@ -792,6 +804,7 @@ where
792
804
}
793
805
}
794
806
807
+ assert ! ( iter. size_hint( ) . 0 >= N ) ;
795
808
try_from_fn ( next ( iter) )
796
809
}
797
810
0 commit comments