Last active
August 22, 2016 10:00
-
-
Save KodrAus/d12dddd485650c6b23270c806b73b95a to your computer and use it in GitHub Desktop.
Rust Structures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Person { | |
pub id: i32, | |
pub title: String | |
} | |
fn main() { | |
//structs are constructed inline. We could use a static method | |
//Rust structures have completely separate data and functionality blocks | |
let person = Person { | |
id: 1, | |
title: "Joe".to_string() | |
}; | |
//Instance paths use '.' and static paths use '::' | |
println!("Title: '{}'", person.title); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment