Skip to content

Instantly share code, notes, and snippets.

@mfpiccolo
Created July 21, 2015 06:26
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 mfpiccolo/8bd0e1f2c65ee50e2e59 to your computer and use it in GitHub Desktop.
Save mfpiccolo/8bd0e1f2c65ee50e2e59 to your computer and use it in GitHub Desktop.
pub struct TwoNumbers {
first: i32,
second: i32,
}
impl TwoNumbers {
fn plus_one_to_each(self) -> TwoNumbers {
let mut tn = self;
tn.first += 1;
tn.second += 1;
tn
}
}
#[no_mangle]
pub extern fn add_one_to_vals(numbers: TwoNumbers) -> TwoNumbers {
numbers.plus_one_to_each()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment