Structs in modules: pub or not pub?

Hi,
I tried the examples from this page, but I have a problem. It only works if I add "pub" in front of the Struct definition in the module

pub struct Meal {
	pub taste: String,
	price: u32,
}

without "pub" it doesn't work. Where is the mistake?

I think the mistake is in the tutorial.

pub means it can be used outside of this module (this file). In your case use food::Meal requires Meal to be pub.

1 Like

Thanks, I was a bit confused by this tutorial.