4646 }
4747}
4848
49+ /// Token type to signify successful initialization.
50+ ///
51+ /// Can only be constructed via the unsafe [`Self::new`] function. The initializer macros use this
52+ /// token type to prevent returning `Ok` from an initializer without initializing all fields.
53+ pub struct InitOk ( ( ) ) ;
54+
55+ impl InitOk {
56+ /// Creates a new token.
57+ ///
58+ /// # Safety
59+ ///
60+ /// This function may only be called from the `init!` macro in `../internal/src/init.rs`.
61+ #[ inline( always) ]
62+ pub unsafe fn new ( ) -> Self {
63+ Self ( ( ) )
64+ }
65+ }
66+
4967/// This trait is only implemented via the `#[pin_data]` proc-macro. It is used to facilitate
5068/// the pin projections within the initializers.
5169///
@@ -68,9 +86,10 @@ pub unsafe trait PinData: Copy {
6886 type Datee : ?Sized + HasPinData ;
6987
7088 /// Type inference helper function.
71- fn make_closure < F , O , E > ( self , f : F ) -> F
89+ #[ inline( always) ]
90+ fn make_closure < F , E > ( self , f : F ) -> F
7291 where
73- F : FnOnce ( * mut Self :: Datee ) -> Result < O , E > ,
92+ F : FnOnce ( * mut Self :: Datee ) -> Result < InitOk , E > ,
7493 {
7594 f
7695 }
@@ -98,9 +117,10 @@ pub unsafe trait InitData: Copy {
98117 type Datee : ?Sized + HasInitData ;
99118
100119 /// Type inference helper function.
101- fn make_closure < F , O , E > ( self , f : F ) -> F
120+ #[ inline( always) ]
121+ fn make_closure < F , E > ( self , f : F ) -> F
102122 where
103- F : FnOnce ( * mut Self :: Datee ) -> Result < O , E > ,
123+ F : FnOnce ( * mut Self :: Datee ) -> Result < InitOk , E > ,
104124 {
105125 f
106126 }
0 commit comments