Skip to content

Instantly share code, notes, and snippets.

@KodrAus
Last active August 22, 2016 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KodrAus/d12dddd485650c6b23270c806b73b95a to your computer and use it in GitHub Desktop.
Save KodrAus/d12dddd485650c6b23270c806b73b95a to your computer and use it in GitHub Desktop.
Rust Structures
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