@@ -1339,31 +1339,45 @@ where
1339
1339
{
1340
1340
type Output = NewOutput ;
1341
1341
1342
- // This opaque type must be defined outside this trait to
1343
- // prevent the unintended capturing of `Binder`.
1344
- // [ref:opaque_type_extraneous_capture]
1345
- type BoundFn = MappedBoundFn < InnerBoundFn , Output , Mapper , NewOutput > ;
1342
+ type BoundFn = MappedBoundFn < InnerBoundFn , Mapper > ;
1346
1343
1347
1344
fn bind ( self , binder : Binder , ctx : & mut CfgBindCtx < ' _ > ) -> Self :: BoundFn {
1348
- map_bind_inner ( self . inner . bind ( binder, ctx) , self . mapper )
1345
+ MappedBoundFn {
1346
+ inner_bound_fn : self . inner . bind ( binder, ctx) ,
1347
+ mapper : self . mapper ,
1348
+ }
1349
1349
}
1350
1350
}
1351
1351
1352
- type MappedBoundFn < InnerBoundFn , Output , Mapper , NewOutput >
1353
- where
1354
- InnerBoundFn : FnOnce ( ) -> Output + Copy + Send + ' static ,
1355
- Mapper : FnOnce ( Output ) -> NewOutput + Copy + Send + ' static ,
1356
- = impl FnOnce ( ) -> NewOutput + Copy + Send + ' static ;
1352
+ // // This opaque type must be defined outside this trait to
1353
+ // // prevent the unintended capturing of `Binder`.
1354
+ // // [ref:opaque_type_extraneous_capture]
1355
+ // type MappedBoundFn<InnerBoundFn, Output, Mapper, NewOutput>
1356
+ // where
1357
+ // InnerBoundFn: FnOnce() -> Output + Copy + Send + 'static,
1358
+ // Mapper: FnOnce(Output) -> NewOutput + Copy + Send + 'static,
1359
+ // = impl FnOnce() -> NewOutput + Copy + Send + 'static;
1357
1360
1358
- const fn map_bind_inner < InnerBoundFn , Output , Mapper , NewOutput > (
1361
+ // FIXME: This is supposed to be a TAIT like the one above, but
1362
+ // [ref:rust_99793_tait] prevents that
1363
+ #[ doc( hidden) ]
1364
+ #[ derive( Copy , Clone ) ]
1365
+ pub struct MappedBoundFn < InnerBoundFn , Mapper > {
1359
1366
inner_bound_fn : InnerBoundFn ,
1360
1367
mapper : Mapper ,
1361
- ) -> MappedBoundFn < InnerBoundFn , Output , Mapper , NewOutput >
1368
+ }
1369
+
1370
+ impl < InnerBoundFn , Output , Mapper , NewOutput > FnOnce < ( ) > for MappedBoundFn < InnerBoundFn , Mapper >
1362
1371
where
1363
1372
InnerBoundFn : FnOnce ( ) -> Output + Copy + Send + ' static ,
1364
1373
Mapper : FnOnce ( Output ) -> NewOutput + Copy + Send + ' static ,
1365
1374
{
1366
- move || ( mapper) ( inner_bound_fn ( ) )
1375
+ type Output = NewOutput ;
1376
+
1377
+ #[ inline]
1378
+ extern "rust-call" fn call_once ( self , ( ) : ( ) ) -> Self :: Output {
1379
+ ( self . mapper ) ( ( self . inner_bound_fn ) ( ) )
1380
+ }
1367
1381
}
1368
1382
1369
1383
// Binder traits
0 commit comments