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

Exercises for understanding the module system #9

Closed
jdm opened this issue Sep 17, 2015 · 2 comments
Closed

Exercises for understanding the module system #9

jdm opened this issue Sep 17, 2015 · 2 comments

Comments

@jdm
Copy link

jdm commented Sep 17, 2015

Here's a straightforward one to start:

// Make this compile!

mod sausage_factory {
    fn make_sausage() {
        println!("sausage!");
    }
}

fn main() {
    sausage_factory::make_sausage();
}
@jdm
Copy link
Author

jdm commented Sep 17, 2015

Another:

// Make this compile!

mod presidential_frontrunners {
    use self::democrats::HILARY_CLINTON as democrat;
    use self::republicans::DONALD_TRUMP as republican;

    mod democrats {
        pub const HILARY_CLINTON: &'static str = "Hilary Clinton";
        pub const BERNIE_SANDERS: &'static str = "Bernie Sanders";
    }

    mod republicans {
        pub const DONALD_TRUMP: &'static str = "Donald Trump";
        pub const JEB_BUSH: &'static str = "Jeb Bush";
    }
}

fn main() {
    println!("candidates: {} and {}",
             presidential_frontrunners::democrat,
             presidential_frontrunners::republican);
}

@carols10cents
Copy link
Member

Added these in a modules section! Thank you!!! I'm adding this one and the std library types ones first since they're less advanced than the other exercises you've made so I wanted to incorporate them first :) I will add the others though, they're awesome!!

xymopen added a commit to xymopen/rustlings-solutions that referenced this issue Oct 14, 2019
ppp3 pushed a commit to ppp3/rustlings that referenced this issue May 23, 2022
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