Last active
August 29, 2015 14:07
-
-
Save bvssvni/84108e1da75267ec19ba to your computer and use it in GitHub Desktop.
pub: + ? + &' to simplify public structs
This file contains 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
#[deriving(Show)] | |
pub struct Stuff<'a> { | |
pub desc: &'a str, | |
pub owner: Option<&'a str>, | |
// pub borrower: Option<&'a str>, | |
pub using: Option<&'a str>, | |
pub key_to: Option<&'a str>, | |
// pub left_hand: Option<&'a str>, | |
// pub right_hand: Option<&'a str>, | |
// pub mother: Option<&'a str>, | |
// pub father: Option<&'a str>, | |
pub strength: i32, | |
// pub lift_strength: i32, | |
// pub push_strength: i32, | |
pub money: i64, | |
pub time: i64, | |
pub speed: i32, | |
pub locked: bool, | |
// pub influence: i32, | |
} |
This file contains 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
#[deriving(Show)] | |
pub: struct Stuff { | |
desc: &'str, | |
owner? &'str, | |
// borrower? &'str, | |
using? &'str, | |
key_to? &'str, | |
// left_hand? &'str, | |
// right_hand? &'str, | |
// mother? &'str, | |
// father? &'str, | |
strength: i32, | |
// lift_strength: i32, | |
// push_strength: i32, | |
money: i64, | |
time: i64, | |
speed: i32, | |
locked: bool, | |
// influence: i32, | |
} |
A question mark instead of :
wraps the type in Option
.
A &'
is a short hand for "lifetime to this struct".
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A colon after
pub
makes all the members public.