auto_enums
auto_enums copied to clipboard
Support returning Result/Option<impl Trait>
I've got a situation where a function returns something like Result<impl Iterator<Item = &str>, MyError>, and it would be very useful to be able to use auto_enum on it. Is this technically possible, or is there perhaps a workaround for it?
I think we can probably support something like this:
#[auto_enum(fmt::Debug)]
fn f() -> Option<impl fmt::Debug> {
if ... {
let opt = ...;
// converted to `return opt.map(|some| Enum::A(some));`
return opt;
}
if ... {
// converted to `return Some(Enum::B(...))`
return Some(...)
}
// converted to `Some(Enum::C(...))`
Some(...)
}
related: #106