1
Fork 0

s/Generator/Coroutine/

This commit is contained in:
Oli Scherer 2023-10-19 16:06:43 +00:00
parent 96027d945b
commit 60956837cf
310 changed files with 1271 additions and 1271 deletions

View file

@ -5,7 +5,7 @@ Erroneous code example:
```compile_fail,E0626
# #![feature(generators, generator_trait, pin)]
# use std::ops::Generator;
# use std::ops::Coroutine;
# use std::pin::Pin;
let mut b = || {
let a = &String::new(); // <-- This borrow...
@ -24,7 +24,7 @@ the integer by value:
```
# #![feature(generators, generator_trait, pin)]
# use std::ops::Generator;
# use std::ops::Coroutine;
# use std::pin::Pin;
let mut b = || {
let a = 3;
@ -42,7 +42,7 @@ This error also frequently arises with iteration:
```compile_fail,E0626
# #![feature(generators, generator_trait, pin)]
# use std::ops::Generator;
# use std::ops::Coroutine;
# use std::pin::Pin;
let mut b = || {
let v = vec![1,2,3];
@ -58,7 +58,7 @@ Such cases can sometimes be resolved by iterating "by value" (or using
```
# #![feature(generators, generator_trait, pin)]
# use std::ops::Generator;
# use std::ops::Coroutine;
# use std::pin::Pin;
let mut b = || {
let v = vec![1,2,3];
@ -73,7 +73,7 @@ If taking ownership is not an option, using indices can work too:
```
# #![feature(generators, generator_trait, pin)]
# use std::ops::Generator;
# use std::ops::Coroutine;
# use std::pin::Pin;
let mut b = || {
let v = vec![1,2,3];

View file

@ -4,24 +4,24 @@ method.
Erroneous code example:
```compile_fail,E0790
trait Generator {
trait Coroutine {
fn create() -> u32;
}
struct Impl;
impl Generator for Impl {
impl Coroutine for Impl {
fn create() -> u32 { 1 }
}
struct AnotherImpl;
impl Generator for AnotherImpl {
impl Coroutine for AnotherImpl {
fn create() -> u32 { 2 }
}
let cont: u32 = Generator::create();
// error, impossible to choose one of Generator trait implementation
let cont: u32 = Coroutine::create();
// error, impossible to choose one of Coroutine trait implementation
// Should it be Impl or AnotherImpl, maybe something else?
```
@ -30,18 +30,18 @@ information to the compiler. In this case, the solution is to use a concrete
type:
```
trait Generator {
trait Coroutine {
fn create() -> u32;
}
struct AnotherImpl;
impl Generator for AnotherImpl {
impl Coroutine for AnotherImpl {
fn create() -> u32 { 2 }
}
let gen1 = AnotherImpl::create();
// if there are multiple methods with same name (different traits)
let gen2 = <AnotherImpl as Generator>::create();
let gen2 = <AnotherImpl as Coroutine>::create();
```