Struct fields are private by default in Rust; add the pub keyword before a field name to make it public. Use pub on specific fields to expose them while keeping others private, or on the struct itself to make the type accessible.
struct User {
pub username: String,
email: String,
}
fn main() {
let user = User {
username: String::from("alice"),
email: String::from("alice@example.com"),
};
println!("{}", user.username);
}