@@ -955,6 +955,7 @@ pub unsafe trait PinInit<T: ?Sized, E = Infallible>: Sized {
955955 /// Ok(())
956956 /// });
957957 /// ```
958+ #[ inline]
958959 fn pin_chain < F > ( self , f : F ) -> ChainPinInit < Self , F , T , E >
959960 where
960961 F : FnOnce ( Pin < & mut T > ) -> Result < ( ) , E > ,
@@ -1003,6 +1004,7 @@ where
10031004 I : PinInit < T , E > ,
10041005 F : FnOnce ( Pin < & mut T > ) -> Result < ( ) , E > ,
10051006{
1007+ #[ inline]
10061008 unsafe fn __init ( self , slot : * mut T ) -> Result < ( ) , E > {
10071009 // SAFETY: All requirements fulfilled since this function is `__init`.
10081010 let slot = unsafe { __internal:: Slot :: < __internal:: Pinned , _ > :: new ( slot) } ;
@@ -1068,6 +1070,7 @@ pub unsafe trait Init<T: ?Sized, E = Infallible>: PinInit<T, E> {
10681070 /// Ok(())
10691071 /// });
10701072 /// ```
1073+ #[ inline]
10711074 fn chain < F > ( self , f : F ) -> ChainInit < Self , F , T , E >
10721075 where
10731076 F : FnOnce ( & mut T ) -> Result < ( ) , E > ,
@@ -1095,6 +1098,7 @@ where
10951098 I : Init < T , E > ,
10961099 F : FnOnce ( & mut T ) -> Result < ( ) , E > ,
10971100{
1101+ #[ inline]
10981102 unsafe fn __init ( self , slot : * mut T ) -> Result < ( ) , E > {
10991103 // SAFETY: All requirements fulfilled since this function is `__init`.
11001104 let slot = unsafe { __internal:: Slot :: < __internal:: Unpinned , _ > :: new ( slot) } ;
@@ -1175,6 +1179,7 @@ pub const unsafe fn init_from_closure<T: ?Sized, E>(
11751179///
11761180/// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a
11771181/// pointer must result in a valid `U`.
1182+ #[ inline]
11781183pub const unsafe fn cast_pin_init < T , U , E > ( init : impl PinInit < T , E > ) -> impl PinInit < U , E > {
11791184 // SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety
11801185 // requirements.
@@ -1187,6 +1192,7 @@ pub const unsafe fn cast_pin_init<T, U, E>(init: impl PinInit<T, E>) -> impl Pin
11871192///
11881193/// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a
11891194/// pointer must result in a valid `U`.
1195+ #[ inline]
11901196pub const unsafe fn cast_init < T , U , E > ( init : impl Init < T , E > ) -> impl Init < U , E > {
11911197 // SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety
11921198 // requirements.
@@ -1283,6 +1289,7 @@ where
12831289/// let array: Box<[usize; 1_000]> = Box::init(init_array_from_fn(|i| i)).unwrap();
12841290/// assert_eq!(array.len(), 1_000);
12851291/// ```
1292+ #[ inline]
12861293pub fn init_array_from_fn < I , const N : usize , T , E > (
12871294 make_init : impl FnMut ( usize ) -> I ,
12881295) -> impl Init < [ T ; N ] , E >
@@ -1307,6 +1314,7 @@ where
13071314/// Arc::pin_init(pin_init_array_from_fn(|i| CMutex::new(i))).unwrap();
13081315/// assert_eq!(array.len(), 1_000);
13091316/// ```
1317+ #[ inline]
13101318pub fn pin_init_array_from_fn < I , const N : usize , T , E > (
13111319 make_init : impl FnMut ( usize ) -> I ,
13121320) -> impl PinInit < [ T ; N ] , E >
@@ -1342,6 +1350,7 @@ where
13421350/// This initializer will first execute `lookup_bar()`, match on it, if it returned an error, the
13431351/// initializer itself will fail with that error. If it returned `Ok`, then it will run the
13441352/// initializer returned by the [`pin_init!`] invocation.
1353+ #[ inline]
13451354pub fn pin_init_scope < T , E , F , I > ( make_init : F ) -> impl PinInit < T , E >
13461355where
13471356 F : FnOnce ( ) -> Result < I , E > ,
@@ -1385,6 +1394,7 @@ where
13851394/// This initializer will first execute `lookup_bar()`, match on it, if it returned an error, the
13861395/// initializer itself will fail with that error. If it returned `Ok`, then it will run the
13871396/// initializer returned by the [`init!`] invocation.
1397+ #[ inline]
13881398pub fn init_scope < T , E , F , I > ( make_init : F ) -> impl Init < T , E >
13891399where
13901400 F : FnOnce ( ) -> Result < I , E > ,
@@ -1409,6 +1419,7 @@ unsafe impl<T> Init<T> for T {}
14091419// SAFETY: the `__init` function always returns `Ok(())` and initializes every field of
14101420// `slot`. Additionally, all pinning invariants of `T` are upheld.
14111421unsafe impl < T > PinInit < T > for T {
1422+ #[ inline]
14121423 unsafe fn __init ( self , slot : * mut T ) -> Result < ( ) , Infallible > {
14131424 // SAFETY: `slot` is valid for writes by the safety requirements of this function.
14141425 unsafe { slot. write ( self ) } ;
@@ -1423,6 +1434,7 @@ unsafe impl<T, E> Init<T, E> for Result<T, E> {}
14231434// - `Ok(())`, `slot` was initialized and all pinned invariants of `T` are upheld.
14241435// - `Err(err)`, slot was not written to.
14251436unsafe impl < T , E > PinInit < T , E > for Result < T , E > {
1437+ #[ inline]
14261438 unsafe fn __init ( self , slot : * mut T ) -> Result < ( ) , E > {
14271439 // SAFETY: `slot` is valid for writes by the safety requirements of this function.
14281440 unsafe { slot. write ( self ?) } ;
@@ -1449,6 +1461,7 @@ pub trait InPlaceWrite<T> {
14491461impl < T > InPlaceWrite < T > for & ' static mut MaybeUninit < T > {
14501462 type Initialized = & ' static mut T ;
14511463
1464+ #[ inline]
14521465 fn write_init < E > ( self , init : impl Init < T , E > ) -> Result < Self :: Initialized , E > {
14531466 let slot = self . as_mut_ptr ( ) ;
14541467
@@ -1459,6 +1472,7 @@ impl<T> InPlaceWrite<T> for &'static mut MaybeUninit<T> {
14591472 unsafe { Ok ( self . assume_init_mut ( ) ) }
14601473 }
14611474
1475+ #[ inline]
14621476 fn write_pin_init < E > ( self , init : impl PinInit < T , E > ) -> Result < Pin < Self :: Initialized > , E > {
14631477 let slot = self . as_mut_ptr ( ) ;
14641478
@@ -1764,13 +1778,15 @@ pub trait Wrapper<T> {
17641778}
17651779
17661780impl < T > Wrapper < T > for UnsafeCell < T > {
1781+ #[ inline]
17671782 fn pin_init < E > ( value_init : impl PinInit < T , E > ) -> impl PinInit < Self , E > {
17681783 // SAFETY: `UnsafeCell<T>` has a compatible layout to `T`.
17691784 unsafe { cast_pin_init ( value_init) }
17701785 }
17711786}
17721787
17731788impl < T > Wrapper < T > for MaybeUninit < T > {
1789+ #[ inline]
17741790 fn pin_init < E > ( value_init : impl PinInit < T , E > ) -> impl PinInit < Self , E > {
17751791 // SAFETY: `MaybeUninit<T>` has a compatible layout to `T`.
17761792 unsafe { cast_pin_init ( value_init) }
@@ -1779,6 +1795,7 @@ impl<T> Wrapper<T> for MaybeUninit<T> {
17791795
17801796#[ cfg( all( feature = "unsafe-pinned" , CONFIG_RUSTC_HAS_UNSAFE_PINNED ) ) ]
17811797impl < T > Wrapper < T > for core:: pin:: UnsafePinned < T > {
1798+ #[ inline]
17821799 fn pin_init < E > ( init : impl PinInit < T , E > ) -> impl PinInit < Self , E > {
17831800 // SAFETY: `UnsafePinned<T>` has a compatible layout to `T`.
17841801 unsafe { cast_pin_init ( init) }
0 commit comments