@@ -74,7 +74,10 @@ use crate::{
7474/// }
7575/// ```
7676#[ derive( Debug ) ]
77- pub struct Tx < DB : sqlx:: Database , E = Error > ( Lease < sqlx:: Transaction < ' static , DB > > , PhantomData < E > ) ;
77+ pub struct Tx < DB : sqlx:: Database , E = Error > {
78+ tx : Lease < sqlx:: Transaction < ' static , DB > > ,
79+ _error : PhantomData < E > ,
80+ }
7881
7982impl < DB : sqlx:: Database , E > Tx < DB , E > {
8083 /// Crate a [`State`] and [`Layer`](crate::Layer) to enable the extractor.
@@ -120,33 +123,33 @@ impl<DB: sqlx::Database, E> Tx<DB, E> {
120123 /// **Note:** trying to use the `Tx` extractor again after calling `commit` will currently
121124 /// generate [`Error::OverlappingExtractors`] errors. This may change in future.
122125 pub async fn commit ( self ) -> Result < ( ) , sqlx:: Error > {
123- self . 0 . steal ( ) . commit ( ) . await
126+ self . tx . steal ( ) . commit ( ) . await
124127 }
125128}
126129
127130impl < DB : sqlx:: Database , E > AsRef < sqlx:: Transaction < ' static , DB > > for Tx < DB , E > {
128131 fn as_ref ( & self ) -> & sqlx:: Transaction < ' static , DB > {
129- & self . 0
132+ & self . tx
130133 }
131134}
132135
133136impl < DB : sqlx:: Database , E > AsMut < sqlx:: Transaction < ' static , DB > > for Tx < DB , E > {
134137 fn as_mut ( & mut self ) -> & mut sqlx:: Transaction < ' static , DB > {
135- & mut self . 0
138+ & mut self . tx
136139 }
137140}
138141
139142impl < DB : sqlx:: Database , E > std:: ops:: Deref for Tx < DB , E > {
140143 type Target = sqlx:: Transaction < ' static , DB > ;
141144
142145 fn deref ( & self ) -> & Self :: Target {
143- & self . 0
146+ & self . tx
144147 }
145148}
146149
147150impl < DB : sqlx:: Database , E > std:: ops:: DerefMut for Tx < DB , E > {
148151 fn deref_mut ( & mut self ) -> & mut Self :: Target {
149- & mut self . 0
152+ & mut self . tx
150153 }
151154}
152155
@@ -171,7 +174,10 @@ where
171174
172175 let tx = ext. get_or_begin ( ) . await ?;
173176
174- Ok ( Self ( tx, PhantomData ) )
177+ Ok ( Self {
178+ tx,
179+ _error : PhantomData ,
180+ } )
175181 } )
176182 }
177183}
0 commit comments