mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 01:34:21 +00:00
28 lines
510 B
Rust
28 lines
510 B
Rust
//@ run-pass
|
|
//@ compile-flags: -g
|
|
|
|
#![feature(coroutines, coroutine_trait)]
|
|
|
|
use std::ops::Coroutine;
|
|
|
|
struct Database;
|
|
|
|
impl Database {
|
|
fn get_connection(&self) -> impl Iterator<Item = ()> {
|
|
Some(()).into_iter()
|
|
}
|
|
|
|
fn check_connection(&self) -> impl Coroutine<Yield = (), Return = ()> + '_ {
|
|
move || {
|
|
let iter = self.get_connection();
|
|
for i in iter {
|
|
yield i
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
Database.check_connection();
|
|
}
|