@@ -173,7 +173,7 @@ impl Transformation {
173173
174174 fn presenter ( & self , accumulator : & TokenStream ) -> TokenStream {
175175 let Self {
176- quantity : _ ,
176+ quantity,
177177 output_type,
178178 entries,
179179 } = self ;
@@ -187,15 +187,41 @@ impl Transformation {
187187 #name: #entry
188188 }
189189 } ) ;
190- quote ! {
191- :: benzina:: __private:: std:: iter:: Iterator :: collect:: <:: benzina:: __private:: std:: vec:: Vec <_>>(
192- :: benzina:: __private:: std:: iter:: Iterator :: map(
193- :: benzina:: __private:: IndexMap :: into_values( #accumulator) ,
194- |item| #output_type {
195- #( #entries) , *
196- }
197- )
190+ let iterator = quote ! {
191+ :: benzina:: __private:: std:: iter:: Iterator :: map(
192+ :: benzina:: __private:: IndexMap :: into_values( #accumulator) ,
193+ |item| #output_type {
194+ #( #entries) , *
195+ }
198196 )
197+ } ;
198+ match quantity {
199+ Quantity :: MaybeOne => {
200+ quote ! {
201+ :: benzina:: __private:: std:: iter:: Iterator :: next(
202+ & mut #iterator
203+ )
204+ }
205+ }
206+ Quantity :: One | Quantity :: AssumeOne => {
207+ quote ! {
208+ match :: benzina:: __private:: std:: iter:: Iterator :: next(
209+ & mut #iterator
210+ ) {
211+ Some ( item) => item,
212+ None => return :: benzina:: __private:: std:: result:: Result :: Err (
213+ :: benzina:: __private:: diesel:: result:: Error :: NotFound
214+ )
215+ }
216+ }
217+ }
218+ Quantity :: AtLeastZero | Quantity :: AtLeastOne => {
219+ quote ! {
220+ :: benzina:: __private:: std:: iter:: Iterator :: collect:: <:: benzina:: __private:: std:: vec:: Vec <_>>(
221+ #iterator
222+ )
223+ }
224+ }
199225 }
200226 }
201227}
@@ -204,7 +230,7 @@ impl NoTransformation {
204230 fn map_type_values ( & self ) -> Vec < TokenStream > {
205231 match self . quantity {
206232 Quantity :: MaybeOne => vec ! [ quote! {
207- Option <_>
233+ :: benzina :: __private :: std :: option :: Option <_>
208234 } ] ,
209235 Quantity :: One | Quantity :: AssumeOne => vec ! [ quote! {
210236 _
0 commit comments