1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-02-03 09:57:30 +02:00
comprehensive-rust/src/structs.md

20 lines
296 B
Markdown
Raw Normal View History

2022-12-21 16:36:30 +01:00
# Structs
Like C and C++, Rust has support for custom structs:
```rust,editable
struct Person {
name: String,
age: u8,
}
fn main() {
let peter = Person {
name: String::from("Peter"),
age: 27,
};
println!("{} is {} years old", peter.name, peter.age);
}
```