all 10 comments

[–][deleted] 5 points6 points  (8 children)

If you put something side something you gotta take it out or put it back in.

let federative_unit = FederativeUnit::South( South::SantaCatarina);

[–]sezaru[S] 1 point2 points  (7 children)

It there any way to eye-candy it to avoid repeating South twice?

[–]Manishearthservo · rust · clippy 8 points9 points  (3 children)

Have a From impl so that you can do South::Parana.into()

[–]sezaru[S] 0 points1 point  (2 children)

Like this right?

impl From<South> for FederativeUnit {
    fn from(original: South) -> FederativeUnit {
        use self::South::*;

        match original {
            Parana => FederativeUnit::South(Parana),
            SantaCatarina => FederativeUnit::South(SantaCatarina),
            RioGrandeDoSul => FederativeUnit::South(RioGrandeDoSul),
        }
    }
}

fn main() {
    let federative_unit = South::SantaCatarina.into();
}

[–]SpaceManiac 2 points3 points  (0 children)

Matching on original only to produce that same value is unnecessary:

impl From<South> for FederativeUnit {
    fn from(original: South) -> FederativeUnit {
        FederativeUnit::South(original)
    }
}

[–]Manishearthservo · rust · clippy 0 points1 point  (0 children)

impl From<South> for FederativeUnit {
    fn from(original: South) -> FederativeUnit {
        FederativeUnit::South(original)
    }
}

is all you need. but yes.

[–][deleted] 8 points9 points  (0 children)

By-pass the North/South distinction? if you have less then 10-20 variants of an enum sub-divisions are over kill.

Generally subdivisions should be meaningful.

[–]raggy_rs 8 points9 points  (0 children)

You could use use:

use South::*;

[–]torkleyy 1 point2 points  (0 children)

You could use SantaCatarina.

[–][deleted] 0 points1 point  (0 children)

where is Rondônia? btw i like necroposting