Skip to content

Add variants to the type namespace #17323

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

Closed
brson opened this issue Sep 16, 2014 · 4 comments · Fixed by #17338
Closed

Add variants to the type namespace #17323

brson opened this issue Sep 16, 2014 · 4 comments · Fixed by #17338
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented.
Milestone

Comments

@brson
Copy link
Contributor

brson commented Sep 16, 2014

Tracking rust-lang/rfcs#234

@brson brson added I-nominated B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. labels Sep 16, 2014
@nrc
Copy link
Member

nrc commented Sep 16, 2014

I have an implementation of this, just needs polish and a rebase...

@SimonSapin
Copy link
Contributor

What is the replacement for serialize::json::List and serialize::json::Object, which currently are both enum variant and types, defined in the same module?

pub enum Json {
    I64(i64),
    U64(u64),
    F64(f64),
    String(String),
    Boolean(bool),
    List(List),
    Object(Object),
    Null,
}
pub type List = Vec<Json>;
pub type Object = TreeMap<String, Json>;

I use that pattern a lot in Servo:

pub struct QualifiedRule { ... }
pub struct AtRule { ... }
pub enum Rule {
    QualifiedRule(QualifiedRule),
    AtRule(AtRule),
}

@pnkfelix
Copy link
Member

Assigning P-backcompat-lang, 1.0 milestone.

@pnkfelix pnkfelix added this to the 1.0 milestone Sep 18, 2014
@nikomatsakis
Copy link
Contributor

@SimonSapin indeed I use it a lot too, but hopefully we'll be able to get it back and better in future, when variant is an actual type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants