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

Instructions not clear for: modules/modules2.rs #1346

Open
archcorsair opened this issue Jan 23, 2023 · 3 comments
Open

Instructions not clear for: modules/modules2.rs #1346

archcorsair opened this issue Jan 23, 2023 · 3 comments
Labels
A-exercises Area: Exercises C-enhancement Category: Enhancement

Comments

@archcorsair
Copy link

// TODO: Fix these use statements
use self::fruits::PEAR as ???
use self::veggies::CUCUMBER as ???

// ... snip

fn main() {
    println!(
        "favorite snacks: {} and {}",
        delicious_snacks::fruit,
        delicious_snacks::veggie
    );
}

At first glance it seems as though the solution would simply be to replace the ??? with respective fruit and veggie;
However after much struggling and leaning on the rust discord community for assistance it was pointed out that the use statement itself should also be changed to pub use. This was not clear in the original problem, as the concept of making an import public is not one I'm accustomed to coming from other languages. The compiler doesn't event suggest this change, making it even more difficult to come to the correct answer without external assistance.

@shadows-withal
Copy link
Member

Yeah, good point, I'd imagine we can probably rewrite this exercise as a whole anyways, it's kind of clunky.

@justin-thurman
Copy link

Including a link to the Rust Book documentation on re-exporting names in the hint might make this one clear enough. I also fumbled with this exercise a bit, but I knew I had read something in the Rust Book about this. I just couldn't remember where it was.

@mo8it mo8it added C-enhancement Category: Enhancement A-exercises Area: Exercises labels Sep 2, 2024
@dlloyd1
Copy link

dlloyd1 commented Nov 7, 2024

In addition to the above, could this exercise benefit from extending the TODO comment directive to include a subtle nod to the fact that each use statement requires two distinct changes or perhaps that fixing the compiler error is a two-stage process here?

Step one: identify and correct the alias in the use statement
Step two: correct the access level of the constant import

The use of ??? here was helpful but made me zone in on it a bit too much, and I think that prevented me understanding what was needed properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exercises Area: Exercises C-enhancement Category: Enhancement
Projects
None yet
Development

No branches or pull requests

5 participants