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

use #[non_exhaustive] instead of Unknown #17

Closed
EverlastingBugstopper opened this issue Sep 21, 2020 · 6 comments
Closed

use #[non_exhaustive] instead of Unknown #17

EverlastingBugstopper opened this issue Sep 21, 2020 · 6 comments
Assignees

Comments

@EverlastingBugstopper
Copy link

EverlastingBugstopper commented Sep 21, 2020

Features Description
instead of having an Unknown variant for types::Vendor, make it #[non_exhaustive] so it's possible to add other variants over time without breaking changes for folks consuming this library.

Current code Sample

pub enum Vendor {
    AppCenter,
    AppVeyor,
    AzurePipelines,
    Bamboo,
    BitbucketPipelines,
    Bitrise,
    Buddy,
    Buildkite,
    CircleCI,
    CirrusCI,
    AWSCodeBuild,
    Codeship,
    Drone,
    DSARI,
    GitLabCI,
    GitHubActions,
    GoCD,
    Heroku,
    Hudson,
    Jenkins,
    MagnumCI,
    NetlifyCI,
    Nevercode,
    Render,
    SailCI,
    Screwdriver,
    Semaphore,
    Shippable,
    SolanoCI,
    StriderCD,
    TaskCluster,
    TeamCity,
    TravisCI,
    ZEITNow,
    Unknown,
}

Proposed code Sample

#[non_exhaustive]
pub enum Vendor {
    AppCenter,
    AppVeyor,
    AzurePipelines,
    Bamboo,
    BitbucketPipelines,
    Bitrise,
    Buddy,
    Buildkite,
    CircleCI,
    CirrusCI,
    AWSCodeBuild,
    Codeship,
    Drone,
    DSARI,
    GitLabCI,
    GitHubActions,
    GoCD,
    Heroku,
    Hudson,
    Jenkins,
    MagnumCI,
    NetlifyCI,
    Nevercode,
    Render,
    SailCI,
    Screwdriver,
    Semaphore,
    Shippable,
    SolanoCI,
    StriderCD,
    TaskCluster,
    TeamCity,
    TravisCI,
    ZEITNow,
}
@sagiegurari
Copy link
Owner

good idea. I will take care of it.
thanks a lot for the feedback

@sagiegurari
Copy link
Owner

the unknown should stay however, because it means i detect its CI env, but cant tell which.

@EverlastingBugstopper
Copy link
Author

i'd argue that the Option tells you if it detects it as a CI env, and adding non_exhaustive means consumers would handle the _ case and that would count as "detecting as CI env but not sure which one it is".

@sagiegurari
Copy link
Owner

ya, as lib consumer. but as provider i need to provide some value.

@EverlastingBugstopper
Copy link
Author

oohhh i see. that makes sense! carry on 😄

sagiegurari added a commit that referenced this issue Sep 22, 2020
Use non_exhaustive for Vendor enum #17
@sagiegurari
Copy link
Owner

released. thanks a lot.

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

No branches or pull requests

2 participants