Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(generators)]
- #![feature(generator_trait)]
- use std::marker::PhantomData;
- use std::ops::Generator;
- trait Trait: 'static { }
- struct Index<T: ?Sized = dyn Trait> {
- id: i32, ty: PhantomData<T>
- }
- fn new_index() -> Index { Index { id: 10, ty: PhantomData } }
- fn with_ctx<F: FnOnce(&mut i32) -> T, T>(f: F) -> T {
- let mut ctx = 123;
- f(&mut ctx)
- }
- fn accept_gen<G: Generator>(g: G) { }
- fn main() {
- accept_gen(static move || {
- let poll = with_ctx(|ctx| new_index());
- yield 20;
- });
- }
Add Comment
Please, Sign In to add comment