9.13 Visibility and Modules
By default, structs and their fields are private within the module. Use pub
to expose them:
pub struct PublicStruct {
pub field: Type,
private_field: Type,
}
You will learn more about modules, crates, and structuring larger projects later. Remember that visibility in Rust is explicit—fields and structs are private unless declared pub
.