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

Optimize #[deriving(ToStr)] for C-style enums #7179

Closed
emberian opened this issue Jun 16, 2013 · 1 comment
Closed

Optimize #[deriving(ToStr)] for C-style enums #7179

emberian opened this issue Jun 16, 2013 · 1 comment
Labels
A-syntaxext Area: Syntax extensions C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@emberian
Copy link
Member

This would simplify the pattern like

enum Foo {
    A,
    B,
    C
}

fn foo_to_str(f: Foo) -> &'static str {
    match f {
        A => "A",
        B => "B",
        C => "C"
    }
}

instead of doing all the fancy reflection.

bors added a commit that referenced this issue Jun 23, 2013
Closes #7180 and #7179.

Before, the `deriving(ToStr)` attribute was essentially `fmt!("%?")`. This changes it to recursively invoke `to_str()` on fields instead of relying on `fmt!`-style things. This seems more natural to me and what should actually be expected.
@metajack
Copy link
Contributor

metajack commented Aug 8, 2013

visiting for triage. this should have been closed by #7204 but github didn't parse the second bug. closing.

@metajack metajack closed this as completed Aug 8, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue May 20, 2021
Trigger [`wrong_self_convention`] only if it has implicit self

Lint [`wrong_self_convention`] only if the impl or trait has `self` _per sé_.

Fixes: rust-lang#7179

changelog: trigger [`wrong_self_convention`] only if it has implicit self
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

2 participants