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

Remove never option in argument position #48

Merged
merged 1 commit into from
Aug 19, 2019
Merged

Remove never option in argument position #48

merged 1 commit into from
Aug 19, 2019

Conversation

taiki-e
Copy link
Owner

@taiki-e taiki-e commented Aug 19, 2019

This removes never option in argument position.

It is easier and more flexible to define your own enum using #[enum_derive] attribute.

#[enum_derive(Iterator)]
enum Either<A, B> {
    A(A),
    B(B),
}

fn foo(x: i32) -> impl Iterator<Item = i32> {
    match x {
        0 => loop {
             return Either::A(1..10);
        },
        1 => loop {
            panic!()
        },
        _ => loop {
            return Either::B(vec![5, 10].into_iter());
        },
    }
}

@taiki-e taiki-e added this to the v0.6 milestone Aug 19, 2019
@taiki-e taiki-e force-pushed the arg-never branch 2 times, most recently from f9167a3 to 1944bc0 Compare August 19, 2019 13:00
@taiki-e
Copy link
Owner Author

taiki-e commented Aug 19, 2019

bors r+

bors bot added a commit that referenced this pull request Aug 19, 2019
48: Remove never option in argument position r=taiki-e a=taiki-e

This removes [`never` option in argument position](https://github.com/taiki-e/auto_enums/blob/96e01340db16dffd5df472f80f830749ce1bc92c/src/lib.rs#L472-L492).

It is easier and more flexible to define your own enum using [`#[enum_derive]` attribute](https://docs.rs/auto_enums/0.5.10/auto_enums/#enum_derive).
```rust
#[enum_derive(Iterator)]
enum Either<A, B> {
    A(A),
    B(B),
}

fn foo(x: i32) -> impl Iterator<Item = i32> {
    match x {
        0 => loop {
             return Either::A(1..10);
        },
        1 => loop {
            panic!()
        },
        _ => loop {
            return Either::B(vec![5, 10].into_iter());
        },
    }
}
```

Co-authored-by: Taiki Endo <te316e89@gmail.com>
@bors
Copy link
Contributor

bors bot commented Aug 19, 2019

Build succeeded

  • taiki-e.auto_enums

@bors bors bot merged commit b4e31cc into master Aug 19, 2019
@taiki-e taiki-e deleted the arg-never branch August 19, 2019 13:13
@taiki-e taiki-e added the A-auto_enum Area: #[auto_enum] label Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-auto_enum Area: #[auto_enum]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant