@@ -82,37 +82,35 @@ pub enum YieldType<I, A> {
82
82
#[ macro_export]
83
83
#[ allow_internal_unstable( fn_traits) ]
84
84
macro_rules! declare_box_region_type {
85
- ( impl $v: vis
86
- $name: ident,
87
- $yield_type: ty,
88
- for ( $( $lifetimes: tt) * ) ,
89
- ( $( $args: ty) ,* ) -> ( $reti: ty, $retc: ty)
90
- ) => {
85
+ ( $v: vis $name: ident, ( $( $args: ty) ,* ) -> ( $reti: ty, $retc: ty) ) => {
91
86
$v struct $name( $crate:: box_region:: PinnedGenerator <
92
87
$reti,
93
- for <$ ( $lifetimes ) * > fn ( ( $( $args, ) * ) ) ,
88
+ fn ( ( $( $args, ) * ) ) ,
94
89
$retc
95
90
>) ;
96
91
97
92
impl $name {
98
- fn new<T : :: std:: ops:: Generator <$crate:: box_region:: Action , Yield = $yield_type, Return = $retc> + ' static >(
99
- generator: T
100
- ) -> ( $reti, Self ) {
93
+ fn new<T >( generator: T ) -> ( $reti, Self )
94
+ where T : :: std:: ops:: Generator <
95
+ $crate:: box_region:: Action ,
96
+ Yield = $crate:: box_region:: YieldType <$reti, fn ( ( $( $args, ) * ) ) >,
97
+ Return = $retc,
98
+ > + ' static {
101
99
let ( initial, pinned) = $crate:: box_region:: PinnedGenerator :: new( generator) ;
102
100
( initial, $name( pinned) )
103
101
}
104
102
105
- $v fn access<F : for <$ ( $lifetimes ) * > FnOnce ( $( $args, ) * ) -> R , R >( & mut self , f: F ) -> R {
103
+ $v fn access<F : FnOnce ( $( $args, ) * ) -> R , R >( & mut self , f: F ) -> R {
106
104
// Turn the FnOnce closure into *mut dyn FnMut()
107
105
// so we can pass it in to the generator
108
106
let mut r = None ;
109
107
let mut f = Some ( f) ;
110
- let mut_f: & mut dyn for <$ ( $lifetimes ) * > FnMut ( ( $( $args, ) * ) ) =
108
+ let mut_f: & mut dyn FnMut ( ( $( $args, ) * ) ) =
111
109
& mut |args| {
112
110
let f = f. take( ) . unwrap( ) ;
113
111
r = Some ( FnOnce :: call_once( f, args) ) ;
114
112
} ;
115
- let mut_f = mut_f as * mut dyn for <$ ( $lifetimes ) * > FnMut ( ( $( $args, ) * ) ) ;
113
+ let mut_f = mut_f as * mut dyn FnMut ( ( $( $args, ) * ) ) ;
116
114
117
115
// Get the generator to call our closure
118
116
unsafe {
@@ -127,36 +125,29 @@ macro_rules! declare_box_region_type {
127
125
self . 0 . complete( )
128
126
}
129
127
130
- fn initial_yield( value: $reti) -> $yield_type {
128
+ fn initial_yield(
129
+ value: $reti,
130
+ ) -> $crate:: box_region:: YieldType <$reti, fn ( ( $( $args, ) * ) ) > {
131
131
$crate:: box_region:: YieldType :: Initial ( value)
132
132
}
133
133
}
134
134
} ;
135
-
136
- ( $v: vis $name: ident, for ( $( $lifetimes: tt) * ) , ( $( $args: ty) ,* ) -> ( $reti: ty, $retc: ty) ) => {
137
- declare_box_region_type!(
138
- impl $v $name,
139
- $crate:: box_region:: YieldType <$reti, for <$( $lifetimes) * > fn ( ( $( $args, ) * ) ) >,
140
- for ( $( $lifetimes) * ) ,
141
- ( $( $args) ,* ) -> ( $reti, $retc)
142
- ) ;
143
- } ;
144
135
}
145
136
146
137
#[ macro_export]
147
138
#[ allow_internal_unstable( fn_traits) ]
148
139
macro_rules! box_region_allow_access {
149
- ( for ( $ ( $lifetimes : tt ) * ) , ( $( $args: ty) ,* ) , ( $( $exprs: expr) ,* ) , $action: ident) => {
140
+ ( ( $( $args: ty) ,* ) , ( $( $exprs: expr) ,* ) , $action: ident) => {
150
141
loop {
151
142
match $action {
152
143
$crate:: box_region:: Action :: Access ( accessor) => {
153
- let accessor: & mut dyn for <$ ( $lifetimes ) * > FnMut ( $( $args) ,* ) = unsafe {
144
+ let accessor: & mut dyn FnMut ( $( $args) ,* ) = unsafe {
154
145
:: std:: mem:: transmute( accessor. get( ) )
155
146
} ;
156
147
( * accessor) ( ( $( $exprs) ,* ) ) ;
157
148
unsafe {
158
149
let marker = $crate:: box_region:: Marker :: <
159
- for <$ ( $lifetimes ) * > fn ( ( $( $args, ) * ) )
150
+ fn ( ( $( $args, ) * ) )
160
151
>:: new( ) ;
161
152
$action = yield $crate:: box_region:: YieldType :: Accessor ( marker) ;
162
153
} ;
0 commit comments