-
-
Save Nemikolh/dc78c69ba764caa447531be0a6c2e896 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(generators, generator_trait)] | |
use std::ops::Generator; | |
use std::mem::size_of; | |
fn test() -> impl Generator<Yield=(), Return=()> { | |
return || { | |
let a: String = "test".into(); | |
yield (); | |
println!("{}", a); | |
} | |
} | |
fn consume<F, O>(f: F) | |
where F: Fn() -> O | |
{ | |
println!("{}", size_of::<O>()); | |
} | |
fn main() { | |
consume(test); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment