@@ -113,6 +113,7 @@ where
113113/// Converts a reference to `T` into a reference to an array of length 1 (without copying).
114114#[ stable( feature = "array_from_ref" , since = "1.53.0" ) ]
115115#[ rustc_const_stable( feature = "const_array_from_ref_shared" , since = "1.63.0" ) ]
116+ #[ inline]
116117pub const fn from_ref < T > ( s : & T ) -> & [ T ; 1 ] {
117118 // SAFETY: Converting `&T` to `&[T; 1]` is sound.
118119 unsafe { & * ( s as * const T ) . cast :: < [ T ; 1 ] > ( ) }
@@ -121,6 +122,7 @@ pub const fn from_ref<T>(s: &T) -> &[T; 1] {
121122/// Converts a mutable reference to `T` into a mutable reference to an array of length 1 (without copying).
122123#[ stable( feature = "array_from_ref" , since = "1.53.0" ) ]
123124#[ rustc_const_unstable( feature = "const_array_from_ref" , issue = "90206" ) ]
125+ #[ inline]
124126pub const fn from_mut < T > ( s : & mut T ) -> & mut [ T ; 1 ] {
125127 // SAFETY: Converting `&mut T` to `&mut [T; 1]` is sound.
126128 unsafe { & mut * ( s as * mut T ) . cast :: < [ T ; 1 ] > ( ) }
@@ -143,13 +145,15 @@ impl fmt::Display for TryFromSliceError {
143145#[ stable( feature = "try_from" , since = "1.34.0" ) ]
144146impl Error for TryFromSliceError {
145147 #[ allow( deprecated) ]
148+ #[ inline]
146149 fn description ( & self ) -> & str {
147150 "could not convert slice to array"
148151 }
149152}
150153
151154#[ stable( feature = "try_from_slice_error" , since = "1.36.0" ) ]
152155impl From < Infallible > for TryFromSliceError {
156+ #[ inline]
153157 fn from ( x : Infallible ) -> TryFromSliceError {
154158 match x { }
155159 }
@@ -173,13 +177,15 @@ impl<T, const N: usize> AsMut<[T]> for [T; N] {
173177
174178#[ stable( feature = "array_borrow" , since = "1.4.0" ) ]
175179impl < T , const N : usize > Borrow < [ T ] > for [ T ; N ] {
180+ #[ inline]
176181 fn borrow ( & self ) -> & [ T ] {
177182 self
178183 }
179184}
180185
181186#[ stable( feature = "array_borrow" , since = "1.4.0" ) ]
182187impl < T , const N : usize > BorrowMut < [ T ] > for [ T ; N ] {
188+ #[ inline]
183189 fn borrow_mut ( & mut self ) -> & mut [ T ] {
184190 self
185191 }
@@ -321,6 +327,7 @@ impl<'a, T, const N: usize> IntoIterator for &'a [T; N] {
321327 type Item = & ' a T ;
322328 type IntoIter = Iter < ' a , T > ;
323329
330+ #[ inline]
324331 fn into_iter ( self ) -> Iter < ' a , T > {
325332 self . iter ( )
326333 }
@@ -331,6 +338,7 @@ impl<'a, T, const N: usize> IntoIterator for &'a mut [T; N] {
331338 type Item = & ' a mut T ;
332339 type IntoIter = IterMut < ' a , T > ;
333340
341+ #[ inline]
334342 fn into_iter ( self ) -> IterMut < ' a , T > {
335343 self . iter_mut ( )
336344 }
@@ -435,6 +443,7 @@ macro_rules! array_impl_default {
435443 { $n: expr, $t: ident $( $ts: ident) * } => {
436444 #[ stable( since = "1.4.0" , feature = "array_default" ) ]
437445 impl <T > Default for [ T ; $n] where T : Default {
446+ #[ inline]
438447 fn default ( ) -> [ T ; $n] {
439448 [ $t:: default ( ) , $( $ts:: default ( ) ) ,* ]
440449 }
@@ -444,6 +453,7 @@ macro_rules! array_impl_default {
444453 { $n: expr, } => {
445454 #[ stable( since = "1.4.0" , feature = "array_default" ) ]
446455 impl <T > Default for [ T ; $n] {
456+ #[ inline]
447457 fn default ( ) -> [ T ; $n] { [ ] }
448458 }
449459 } ;
@@ -541,13 +551,15 @@ impl<T, const N: usize> [T; N] {
541551 /// Returns a slice containing the entire array. Equivalent to `&s[..]`.
542552 #[ stable( feature = "array_as_slice" , since = "1.57.0" ) ]
543553 #[ rustc_const_stable( feature = "array_as_slice" , since = "1.57.0" ) ]
554+ #[ inline]
544555 pub const fn as_slice ( & self ) -> & [ T ] {
545556 self
546557 }
547558
548559 /// Returns a mutable slice containing the entire array. Equivalent to
549560 /// `&mut s[..]`.
550561 #[ stable( feature = "array_as_slice" , since = "1.57.0" ) ]
562+ #[ inline]
551563 pub fn as_mut_slice ( & mut self ) -> & mut [ T ] {
552564 self
553565 }
@@ -783,7 +795,7 @@ where
783795 R : Try < Output = T > ,
784796 R :: Residual : Residual < [ T ; N ] > ,
785797{
786- assert ! ( iter . size_hint ( ) . 0 >= N ) ;
798+ # [ inline ]
787799 fn next < T > ( mut iter : impl UncheckedIterator < Item = T > ) -> impl FnMut ( usize ) -> T {
788800 move |_| {
789801 // SAFETY: We know that `from_fn` will call this at most N times,
@@ -792,6 +804,7 @@ where
792804 }
793805 }
794806
807+ assert ! ( iter. size_hint( ) . 0 >= N ) ;
795808 try_from_fn ( next ( iter) )
796809}
797810
0 commit comments