Merge pull request #606 from solson/rustup

Rustup
This commit is contained in:
Ralf Jung 2019-01-30 12:58:17 +01:00 committed by GitHub
commit a9505a8fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -1 +1 @@
nightly-2019-01-28 nightly-2019-01-30

View File

@ -11,12 +11,15 @@
#![feature(generators, generator_trait)] #![feature(generators, generator_trait)]
use std::ops::{GeneratorState, Generator}; use std::ops::{GeneratorState, Generator};
use std::pin::Pin;
fn finish<T>(mut amt: usize, mut t: T) -> T::Return fn finish<T>(mut amt: usize, mut t: T) -> T::Return
where T: Generator<Yield = usize> where T: Generator<Yield = usize>
{ {
// We are not moving the `t` around until it gets dropped, so this is okay.
let mut t = unsafe { Pin::new_unchecked(&mut t) };
loop { loop {
match unsafe { t.resume() } { match t.as_mut().resume() {
GeneratorState::Yielded(y) => amt -= y, GeneratorState::Yielded(y) => amt -= y,
GeneratorState::Complete(ret) => { GeneratorState::Complete(ret) => {
assert_eq!(amt, 0); assert_eq!(amt, 0);