@@ -13,6 +13,7 @@ use crate::task::{Context, Poll};
1313#[ unstable( feature = "async_iterator" , issue = "79024" ) ]
1414#[ must_use = "async iterators do nothing unless polled" ]
1515#[ doc( alias = "Stream" ) ]
16+ #[ cfg_attr( not( bootstrap) , lang = "async_iterator" ) ]
1617pub trait AsyncIterator {
1718 /// The type of items yielded by the async iterator.
1819 type Item ;
@@ -109,3 +110,27 @@ where
109110 ( * * self ) . size_hint ( )
110111 }
111112}
113+
114+ #[ unstable( feature = "async_gen_internals" , issue = "none" ) ]
115+ impl < T > Poll < Option < T > > {
116+ /// A helper function for internal desugaring -- produces `Ready(Some(t))`,
117+ /// which corresponds to the async iterator yielding a value.
118+ #[ unstable( feature = "async_gen_internals" , issue = "none" ) ]
119+ #[ cfg_attr( not( bootstrap) , lang = "AsyncGenReady" ) ]
120+ pub fn async_gen_ready ( t : T ) -> Self {
121+ Poll :: Ready ( Some ( t) )
122+ }
123+
124+ /// A helper constant for internal desugaring -- produces `Pending`,
125+ /// which corresponds to the async iterator pending on an `.await`.
126+ #[ unstable( feature = "async_gen_internals" , issue = "none" ) ]
127+ #[ cfg_attr( not( bootstrap) , lang = "AsyncGenPending" ) ]
128+ // FIXME(gen_blocks): This probably could be deduplicated.
129+ pub const PENDING : Self = Poll :: Pending ;
130+
131+ /// A helper constant for internal desugaring -- produces `Ready(None)`,
132+ /// which corresponds to the async iterator finishing its iteration.
133+ #[ unstable( feature = "async_gen_internals" , issue = "none" ) ]
134+ #[ cfg_attr( not( bootstrap) , lang = "AsyncGenFinished" ) ]
135+ pub const FINISHED : Self = Poll :: Ready ( None ) ;
136+ }
0 commit comments