Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Expect" getters #6

Open
alekratz opened this issue Jul 22, 2017 · 0 comments
Open

"Expect" getters #6

alekratz opened this issue Jul 22, 2017 · 0 comments

Comments

@alekratz
Copy link
Owner

Would it make sense to have a getter that returns a Result<&T, E>? e.g.

#[derive(EnumExpectGetters)]
enum MyEnum {
    Foo(i32),
    Bar(String),
}

fn main() {
    let foo = MyEnum::Foo(i32);
    let oops = "You can't do that!";
    assert_eq!(foo.expect_bar::<&str>(oops), Err(oops));
}

or something like that? The only major problem I can immediately see is with it conflicting with result types that have one or both type parameters filled out (e.g. error-chain or std::io::Result).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant