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

Highlight default enum variant #2206

Closed
omid opened this issue Sep 1, 2023 · 1 comment
Closed

Highlight default enum variant #2206

omid opened this issue Sep 1, 2023 · 1 comment

Comments

@omid
Copy link

omid commented Sep 1, 2023

Since Rust has introduced #[default], can we hightlight it in the doc?
Like this one:

#[derive(Default)]
enum Status {
    #[default]
    Active,
    Inactive,
}

For other type of default definition of enums, it can be hard! For example, the following code, can be hard:

#[derive(...)]
enum Status {
    Active,
    Inactive,
}

impl Default for Status {
    fn default() -> Self {
        serde::from_str("active").unwrap()
    }
}

or:

#[derive(...)]
enum Status {
    Active,
    Inactive,
}

impl Default for Status {
    fn default() -> Self {
        if env!("ENV") == "prod" {
            Self::Inactive
        } else {
            Self::Active
        }
    }
}

We can ignore these cases.

@omid omid closed this as completed Sep 1, 2023
@omid
Copy link
Author

omid commented Sep 1, 2023

I think it's related to cargo doc itself, not here

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

1 participant