promptly icon indicating copy to clipboard operation
promptly copied to clipboard

Idea: enum prompts

Open tennox opened this issue 8 months ago • 0 comments

I'm not sure if possible to do it in a similarily magic way as the rest of your code, but something like this would be great:

Failed to foo, do you want to continue? ( y[es] / n[o] / r[etry] )

With code similar to this (using e.g. strum crate for enum introspection)

#[derive(Debug, EnumIter)]
pub enum YNR {
    Yes,
    No,
    Retry,
}
loop {
    match prompt("Failed to foo, do you want to continue?")? {
                YNR::Yes => ..
                YNR::No => ..
                YNR::Retry => continue,
    }
}

tennox avatar Nov 27 '23 19:11 tennox