rustlings icon indicating copy to clipboard operation
rustlings copied to clipboard

Instructions not clear for: `modules/modules2.rs`

Open archcorsair opened this issue 2 years ago • 2 comments

// 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.

archcorsair avatar Jan 23 '23 00:01 archcorsair

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

shadows-withal avatar Jan 26 '23 19:01 shadows-withal

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.

justin-thurman avatar Mar 08 '23 14:03 justin-thurman