@@ -3,13 +3,13 @@ use crate::pin::Pin;
33
44/// The result of a generator resumption.
55///
6- /// This enum is returned from the `Generator ::resume` method and indicates the
6+ /// This enum is returned from the `Coroutine ::resume` method and indicates the
77/// possible return values of a generator. Currently this corresponds to either
88/// a suspension point (`Yielded`) or a termination point (`Complete`).
99#[ derive( Clone , Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash ) ]
1010#[ lang = "generator_state" ]
1111#[ unstable( feature = "generator_trait" , issue = "43122" ) ]
12- pub enum GeneratorState < Y , R > {
12+ pub enum CoroutineState < Y , R > {
1313 /// The generator suspended with a value.
1414 ///
1515 /// This state indicates that a generator has been suspended, and typically
@@ -28,7 +28,7 @@ pub enum GeneratorState<Y, R> {
2828
2929/// The trait implemented by builtin generator types.
3030///
31- /// Generators , also commonly referred to as coroutines, are currently an
31+ /// Coroutines , also commonly referred to as coroutines, are currently an
3232/// experimental language feature in Rust. Added in [RFC 2033] generators are
3333/// currently intended to primarily provide a building block for async/await
3434/// syntax but will likely extend to also providing an ergonomic definition for
@@ -41,7 +41,7 @@ pub enum GeneratorState<Y, R> {
4141/// ```rust
4242/// #![feature(generators, generator_trait)]
4343///
44- /// use std::ops::{Generator, GeneratorState };
44+ /// use std::ops::{Coroutine, CoroutineState };
4545/// use std::pin::Pin;
4646///
4747/// fn main() {
@@ -51,11 +51,11 @@ pub enum GeneratorState<Y, R> {
5151/// };
5252///
5353/// match Pin::new(&mut generator).resume(()) {
54- /// GeneratorState ::Yielded(1) => {}
54+ /// CoroutineState ::Yielded(1) => {}
5555/// _ => panic!("unexpected return from resume"),
5656/// }
5757/// match Pin::new(&mut generator).resume(()) {
58- /// GeneratorState ::Complete("foo") => {}
58+ /// CoroutineState ::Complete("foo") => {}
5959/// _ => panic!("unexpected return from resume"),
6060/// }
6161/// }
@@ -68,7 +68,7 @@ pub enum GeneratorState<Y, R> {
6868#[ lang = "generator" ]
6969#[ unstable( feature = "generator_trait" , issue = "43122" ) ]
7070#[ fundamental]
71- pub trait Generator < R = ( ) > {
71+ pub trait Coroutine < R = ( ) > {
7272 /// The type of value this generator yields.
7373 ///
7474 /// This associated type corresponds to the `yield` expression and the
@@ -95,10 +95,10 @@ pub trait Generator<R = ()> {
9595 ///
9696 /// # Return value
9797 ///
98- /// The `GeneratorState ` enum returned from this function indicates what
98+ /// The `CoroutineState ` enum returned from this function indicates what
9999 /// state the generator is in upon returning. If the `Yielded` variant is
100100 /// returned then the generator has reached a suspension point and a value
101- /// has been yielded out. Generators in this state are available for
101+ /// has been yielded out. Coroutines in this state are available for
102102 /// resumption at a later point.
103103 ///
104104 /// If `Complete` is returned then the generator has completely finished
@@ -110,26 +110,26 @@ pub trait Generator<R = ()> {
110110 /// This function may panic if it is called after the `Complete` variant has
111111 /// been returned previously. While generator literals in the language are
112112 /// guaranteed to panic on resuming after `Complete`, this is not guaranteed
113- /// for all implementations of the `Generator ` trait.
114- fn resume ( self : Pin < & mut Self > , arg : R ) -> GeneratorState < Self :: Yield , Self :: Return > ;
113+ /// for all implementations of the `Coroutine ` trait.
114+ fn resume ( self : Pin < & mut Self > , arg : R ) -> CoroutineState < Self :: Yield , Self :: Return > ;
115115}
116116
117117#[ unstable( feature = "generator_trait" , issue = "43122" ) ]
118- impl < G : ?Sized + Generator < R > , R > Generator < R > for Pin < & mut G > {
118+ impl < G : ?Sized + Coroutine < R > , R > Coroutine < R > for Pin < & mut G > {
119119 type Yield = G :: Yield ;
120120 type Return = G :: Return ;
121121
122- fn resume ( mut self : Pin < & mut Self > , arg : R ) -> GeneratorState < Self :: Yield , Self :: Return > {
122+ fn resume ( mut self : Pin < & mut Self > , arg : R ) -> CoroutineState < Self :: Yield , Self :: Return > {
123123 G :: resume ( ( * self ) . as_mut ( ) , arg)
124124 }
125125}
126126
127127#[ unstable( feature = "generator_trait" , issue = "43122" ) ]
128- impl < G : ?Sized + Generator < R > + Unpin , R > Generator < R > for & mut G {
128+ impl < G : ?Sized + Coroutine < R > + Unpin , R > Coroutine < R > for & mut G {
129129 type Yield = G :: Yield ;
130130 type Return = G :: Return ;
131131
132- fn resume ( mut self : Pin < & mut Self > , arg : R ) -> GeneratorState < Self :: Yield , Self :: Return > {
132+ fn resume ( mut self : Pin < & mut Self > , arg : R ) -> CoroutineState < Self :: Yield , Self :: Return > {
133133 G :: resume ( Pin :: new ( & mut * self ) , arg)
134134 }
135135}
0 commit comments