Move formatting to different function

This slims down the generator MIR considerably, which makes debugging
easier
This commit is contained in:
Jonas Schievink 2020-03-04 17:45:51 +01:00
parent 2b0cfa5b4c
commit 3b6a5fbece

View File

@ -4,11 +4,15 @@
use std::ops::{Generator, GeneratorState};
fn mkstr(my_name: String, my_mood: String) -> String {
format!("{} is {}", my_name.trim(), my_mood.trim())
}
fn my_scenario() -> impl Generator<String, Yield = &'static str, Return = String> {
|_arg: String| {
let my_name = yield "What is your name?";
let my_mood = yield "How are you feeling?";
format!("{} is {}", my_name.trim(), my_mood.trim())
mkstr(my_name, my_mood)
}
}